-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add topology and gossip interface to node
- Loading branch information
Showing
9 changed files
with
179 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use std::{marker::PhantomData, sync::Arc}; | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use draco_interfaces::{ | ||
signer::SignerInterface, ConfigConsumer, GossipInterface, GossipSubscriberInterface, | ||
NotifierInterface, TopologyInterface, WithStartAndShutdown, | ||
}; | ||
use serde::de::DeserializeOwned; | ||
|
||
use super::config::Config; | ||
|
||
pub struct Gossip<S: SignerInterface, Topo: TopologyInterface, N: NotifierInterface> { | ||
signer: PhantomData<S>, | ||
topology: PhantomData<Topo>, | ||
notifier: PhantomData<N>, | ||
} | ||
|
||
#[async_trait] | ||
impl<S: SignerInterface, Topo: TopologyInterface, N: NotifierInterface + Send + Sync> | ||
WithStartAndShutdown for Gossip<S, Topo, N> | ||
{ | ||
/// Returns true if this system is running or not. | ||
fn is_running(&self) -> bool { | ||
todo!() | ||
} | ||
|
||
/// Start the system, should not do anything if the system is already | ||
/// started. | ||
async fn start(&self) { | ||
todo!() | ||
} | ||
|
||
/// Send the shutdown signal to the system. | ||
async fn shutdown(&self) { | ||
todo!() | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<S: SignerInterface, Topo: TopologyInterface, N: NotifierInterface + Send + Sync> | ||
GossipInterface for Gossip<S, Topo, N> | ||
{ | ||
type Signer = S; | ||
|
||
type Topology = Topo; | ||
|
||
type Notifier = N; | ||
|
||
type Subscriber<T: DeserializeOwned + Send + Sync> = GossipSubscriber<T>; | ||
|
||
async fn init( | ||
_config: Self::Config, | ||
_topology: Arc<Self::Topology>, | ||
_signer: &Self::Signer, | ||
) -> Result<Self> { | ||
todo!() | ||
} | ||
|
||
fn subscribe<T>(&self, _topic: draco_interfaces::Topic) -> Self::Subscriber<T> | ||
where | ||
T: DeserializeOwned + Send + Sync, | ||
{ | ||
todo!() | ||
} | ||
|
||
fn broadcast_socket(&self) -> affair::Socket<draco_interfaces::GossipMessage, ()> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<S: SignerInterface, Topo: TopologyInterface, N: NotifierInterface> ConfigConsumer | ||
for Gossip<S, Topo, N> | ||
{ | ||
type Config = Config; | ||
|
||
const KEY: &'static str = "GOSSIP"; | ||
} | ||
|
||
pub struct GossipSubscriber<T>(PhantomData<T>); | ||
|
||
#[async_trait] | ||
impl<T> GossipSubscriberInterface<T> for GossipSubscriber<T> | ||
where | ||
T: DeserializeOwned + Send + Sync, | ||
{ | ||
async fn recv(&mut self) -> Option<T> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
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 signer; | ||
pub mod topology; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::{marker::PhantomData, sync::Arc}; | ||
|
||
use async_trait::async_trait; | ||
use draco_interfaces::{ConfigConsumer, SyncQueryRunnerInterface, TopologyInterface}; | ||
use fleek_crypto::NodePublicKey; | ||
|
||
use super::config::Config; | ||
|
||
pub struct Topology<Q: SyncQueryRunnerInterface> { | ||
query: PhantomData<Q>, | ||
} | ||
|
||
#[async_trait] | ||
impl<Q: SyncQueryRunnerInterface> TopologyInterface for Topology<Q> { | ||
type SyncQuery = Q; | ||
|
||
async fn init( | ||
_config: Self::Config, | ||
_our_public_key: NodePublicKey, | ||
_query_runner: Self::SyncQuery, | ||
) -> anyhow::Result<Self> { | ||
todo!() | ||
} | ||
|
||
fn suggest_connections(&self) -> Arc<Vec<Vec<NodePublicKey>>> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<Q: SyncQueryRunnerInterface> ConfigConsumer for Topology<Q> { | ||
type Config = Config; | ||
|
||
const KEY: &'static str = "TOPOLOGY"; | ||
} |