Skip to content

Commit

Permalink
Fixed templates and added finished interfaces to node to not panic wh…
Browse files Browse the repository at this point in the history
…en running binary
  • Loading branch information
daltoncoder committed Jul 11, 2023
1 parent a0299c2 commit 3ee6e21
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 183 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2245,11 +2245,13 @@ dependencies = [
"bytes",
"clap 4.3.8",
"draco-application",
"draco-blockstore",
"draco-consensus",
"draco-handshake",
"draco-interfaces",
"draco-notifier",
"draco-rep-collector",
"draco-rpc",
"draco-signer",
"fleek-crypto",
"mockall",
Expand Down
2 changes: 1 addition & 1 deletion core/blockstore/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Default)]
pub struct Config;
pub struct Config {}
14 changes: 7 additions & 7 deletions core/blockstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod tests {
// Given: some content.
let content = create_content();
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// When: we create a putter and write some content.
let mut putter = blockstore.put(None);
putter
Expand All @@ -87,7 +87,7 @@ mod tests {
// Given: some content.
let content = create_content();
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// Given: we put the content in the block store.
let mut putter = blockstore.put(None);
putter
Expand Down Expand Up @@ -115,7 +115,7 @@ mod tests {
// Given: some content.
let mut content = create_content();
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// Given: we put the content in the block store and feed the proof to verify it.
let mut putter = blockstore.put(None);
putter
Expand All @@ -141,7 +141,7 @@ mod tests {
// Given: some content.
let content = create_content();
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// Given: we put the content in the block store.
let mut putter = blockstore.put(None);
putter
Expand Down Expand Up @@ -178,7 +178,7 @@ mod tests {
// Given: some content.
let content = [0; BLAKE3_CHUNK_SIZE];
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// Given: we put the content in the block store.
let mut putter = blockstore.put(None);
putter
Expand All @@ -204,7 +204,7 @@ mod tests {
// Given: some content.
let content = [0; 256];
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// Given: we put the content in the block store.
let mut putter = blockstore.put(None);
putter
Expand Down Expand Up @@ -233,7 +233,7 @@ mod tests {
.flatten()
.collect::<Vec<_>>();
// Given: a block store.
let blockstore = MemoryBlockStore::init(Config).await.unwrap();
let blockstore = MemoryBlockStore::init(Config {}).await.unwrap();
// Given: we put the content in the block store.
let mut putter = blockstore.put(None);
putter
Expand Down
2 changes: 2 additions & 0 deletions core/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ default-run = "draco-node"

[dependencies]
draco-application = { path = "../application" }
draco-blockstore = { path = "../blockstore" }
draco-handshake = { path = "../handshake" }
draco-interfaces = { path = "../interfaces" }
draco-rep-collector = { path = "../rep-collector" }
draco-consensus = { path = "../consensus" }
draco-notifier = { path = "../notifier" }
draco-rpc = { path = "../rpc" }
draco-signer = { path = "../signer" }
anyhow.workspace = true
clap = { version = "4.2", features = ["derive"] }
Expand Down
8 changes: 5 additions & 3 deletions core/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ use std::{path::PathBuf, sync::Arc};
use anyhow::Result;
use clap::Parser;
use draco_application::{app::Application, query_runner::QueryRunner};
use draco_blockstore::memory::MemoryBlockStore;
use draco_consensus::consensus::Consensus;
use draco_handshake::server::{StreamProvider, TcpHandshakeServer, TcpProvider};
use draco_interfaces::{common::WithStartAndShutdown as _, ConfigProviderInterface, Node};
use draco_notifier::Notifier;
use draco_rep_collector::ReputationAggregator;
use draco_rpc::server::Rpc;
use draco_signer::Signer;
use template::{gossip::Gossip, topology::Topology};

Expand All @@ -21,16 +23,16 @@ use crate::{
config::TomlConfigProvider,
shutdown::ShutdownController,
template::{
blockstore::BlockStore, fs::FileSystem, indexer::Indexer, origin::MyStream,
pod::DeliveryAcknowledgmentAggregator, rpc::Rpc, sdk::Sdk,
fs::FileSystem, indexer::Indexer, origin::MyStream, pod::DeliveryAcknowledgmentAggregator,
sdk::Sdk,
},
};

pub type ConcreteNode = Node<
TomlConfigProvider,
Consensus<QueryRunner, Gossip<Signer, Topology<QueryRunner>, Notifier>>,
Application,
BlockStore,
MemoryBlockStore,
Indexer,
FileSystem,
Signer,
Expand Down
109 changes: 0 additions & 109 deletions core/node/src/template/blockstore.rs

This file was deleted.

7 changes: 4 additions & 3 deletions core/node/src/template/fs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use async_trait::async_trait;
use draco_blockstore::memory::MemoryBlockStore;
use draco_interfaces::{
blockstore::BlockStoreInterface, common::WithStartAndShutdown, config::ConfigConsumer,
fs::FileSystemInterface, Blake3Hash, Blake3Tree, CompressionAlgoSet, ContentChunk,
};

use super::config::Config;
use crate::{BlockStore, Indexer};
use crate::Indexer;

#[derive(Clone)]
pub struct FileSystem {}
Expand All @@ -32,13 +33,13 @@ impl WithStartAndShutdown for FileSystem {
#[async_trait]
impl FileSystemInterface for FileSystem {
/// The block store used for this file system.
type BlockStore = BlockStore;
type BlockStore = MemoryBlockStore;

/// The indexer used for this file system.
type Indexer = Indexer;

fn new(_store: &Self::BlockStore, _indexer: &Self::Indexer) -> Self {
todo!()
Self {}
}

/// Returns true if the given `cid` is already cached on the node.
Expand Down
6 changes: 5 additions & 1 deletion core/node/src/template/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ impl<S: SignerInterface, Topo: TopologyInterface, N: NotifierInterface + Send +
_topology: Arc<Self::Topology>,
_signer: &Self::Signer,
) -> Result<Self> {
todo!()
Ok(Self {
signer: PhantomData,
topology: PhantomData,
notifier: PhantomData,
})
}

fn subscribe<T>(&self, _topic: draco_interfaces::Topic) -> Self::Subscriber<T>
Expand Down
2 changes: 1 addition & 1 deletion core/node/src/template/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl WithStartAndShutdown for Indexer {
#[async_trait]
impl IndexerInterface for Indexer {
async fn init(_config: Self::Config) -> anyhow::Result<Self> {
todo!()
Ok(Self {})
}

/// Publish to everyone that we have cached a content with the given `cid` successfully.
Expand Down
2 changes: 0 additions & 2 deletions core/node/src/template/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pub mod blockstore;
pub mod config;
pub mod fs;
pub mod gossip;
pub mod indexer;
pub mod origin;
pub mod pod;
pub mod rpc;
pub mod sdk;
pub mod topology;
2 changes: 1 addition & 1 deletion core/node/src/template/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl WithStartAndShutdown for DeliveryAcknowledgmentAggregator {
impl DeliveryAcknowledgmentAggregatorInterface for DeliveryAcknowledgmentAggregator {
/// Initialize a new delivery acknowledgment aggregator.
async fn init(_config: Self::Config, _submit_tx: SubmitTxSocket) -> anyhow::Result<Self> {
todo!()
Ok(Self {})
}

/// Returns the socket that can be used to submit delivery acknowledgments to be aggregated.
Expand Down
54 changes: 0 additions & 54 deletions core/node/src/template/rpc.rs

This file was deleted.

2 changes: 1 addition & 1 deletion core/node/src/template/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<Q: SyncQueryRunnerInterface> TopologyInterface for Topology<Q> {
_our_public_key: NodePublicKey,
_query_runner: Self::SyncQuery,
) -> anyhow::Result<Self> {
todo!()
Ok(Self { query: PhantomData })
}

fn suggest_connections(&self) -> Arc<Vec<Vec<NodePublicKey>>> {
Expand Down

0 comments on commit 3ee6e21

Please sign in to comment.