Skip to content

Commit

Permalink
ported db code
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiharini committed Nov 8, 2024
1 parent e6b4380 commit 139f55a
Show file tree
Hide file tree
Showing 8 changed files with 683 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ malachite-config = { path = "../malachite/code/crates/config" }
malachite-node = { path = "../malachite/code/crates/node" }
malachite-metrics = { path = "../malachite/code/crates/metrics" }
blake3 = "1.4.1"

tracing = "0.1.40"
thiserror = "1.0.66"
reqwest = { version = "0.12.9", features = ["json"] }
Expand All @@ -40,7 +39,8 @@ url = "2.5.3"
alloy-transport = "0.5.4"
alloy-sol-types = "0.8.11"
ed25519-dalek = "2.1.1"

rocksdb = {version="0.22.0", features=["multi-threaded-cf"]}
walkdir = "2.5.0"

[build-dependencies]
tonic-build = "0.9.2"
Expand Down
19 changes: 13 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod storage;
use clap::Parser;
use futures::stream::StreamExt;
use libp2p::identity::ed25519::Keypair;
Expand All @@ -15,15 +16,17 @@ use tonic::transport::Server;
use tracing::{error, info};
use tracing_subscriber::EnvFilter;

use snapchain::consensus::consensus::{BlockProposer, Consensus, ConsensusMsg, ConsensusParams, ShardValidator, SystemMessage};
use snapchain::consensus::consensus::{
BlockProposer, Consensus, ConsensusMsg, ConsensusParams, ShardValidator, SystemMessage,
};
use snapchain::core::types::{
proto, Address, Height, ShardId, SnapchainShard, SnapchainValidator, SnapchainValidatorContext,
SnapchainValidatorSet,
};
use snapchain::network::gossip::GossipEvent;
use snapchain::network::gossip::SnapchainGossip;
use snapchain::proto::rpc::snapchain_service_server::SnapchainServiceServer;
use snapchain::network::server::MySnapchainService;
use snapchain::proto::rpc::snapchain_service_server::SnapchainServiceServer;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -65,7 +68,10 @@ async fn main() -> Result<(), Box<dyn Error>> {

let keypair = app_config.consensus.keypair().clone();

info!("Starting Snapchain node with public key: {}", hex::encode(keypair.public().to_bytes()));
info!(
"Starting Snapchain node with public key: {}",
hex::encode(keypair.public().to_bytes())
);

let (system_tx, mut system_rx) = mpsc::channel::<SystemMessage>(100);

Expand Down Expand Up @@ -142,7 +148,8 @@ async fn main() -> Result<(), Box<dyn Error>> {

let ctx = SnapchainValidatorContext::new(keypair.clone());
let block_proposer = BlockProposer::new(validator_address.clone(), shard.clone());
let shard_validator = ShardValidator::new(validator_address.clone(), Some(block_proposer), None);
let shard_validator =
ShardValidator::new(validator_address.clone(), Some(block_proposer), None);
let consensus_actor = Consensus::spawn(
ctx,
shard,
Expand All @@ -153,8 +160,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
gossip_tx.clone(),
shard_validator,
)
.await
.unwrap();
.await
.unwrap();

// Create a timer for block creation
let mut block_interval = time::interval(Duration::from_secs(2));
Expand Down
3 changes: 3 additions & 0 deletions src/storage/db/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub use self::rocksdb::*;

mod rocksdb;
Loading

0 comments on commit 139f55a

Please sign in to comment.