Implement chrs-election: Stateful weighted leader election following original CHORUS specs
This commit is contained in:
@@ -25,6 +25,7 @@ pub struct BusMessage {
|
||||
}
|
||||
|
||||
/// A handle to interact with the P2P bus from the agent.
|
||||
#[derive(Clone)]
|
||||
pub struct BusHandle {
|
||||
pub outgoing_tx: mpsc::UnboundedSender<(String, Vec<u8>)>, // (topic, data)
|
||||
pub local_peer_id: PeerId,
|
||||
@@ -79,8 +80,13 @@ impl SwarmManager {
|
||||
// Subscribe to default topics
|
||||
let global_topic = gossipsub::IdentTopic::new("chorus-global");
|
||||
let heartbeat_topic = gossipsub::IdentTopic::new("chorus-heartbeat");
|
||||
let election_topic = gossipsub::IdentTopic::new("CHORUS/election/v1");
|
||||
let admin_heartbeat_topic = gossipsub::IdentTopic::new("CHORUS/admin/heartbeat/v1");
|
||||
|
||||
swarm.behaviour_mut().gossipsub.subscribe(&global_topic)?;
|
||||
swarm.behaviour_mut().gossipsub.subscribe(&heartbeat_topic)?;
|
||||
swarm.behaviour_mut().gossipsub.subscribe(&election_topic)?;
|
||||
swarm.behaviour_mut().gossipsub.subscribe(&admin_heartbeat_topic)?;
|
||||
|
||||
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user