mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Complete moving network logc into beacon node
This commit is contained in:
@@ -4,6 +4,10 @@ use serde_derive::{Deserialize, Serialize};
|
||||
use types::multiaddr::{Error as MultiaddrError, Multiaddr};
|
||||
//use std::time::Duration;
|
||||
|
||||
/// The beacon node topic string to subscribe to.
|
||||
pub const BEACON_PUBSUB_TOPIC: &str = "beacon_node";
|
||||
pub const SHARD_TOPIC_PREFIX: &str = "attestations"; // single topic for all attestation for the moment.
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
/// Network configuration for lighthouse.
|
||||
@@ -22,10 +26,6 @@ pub struct Config {
|
||||
pub client_version: String,
|
||||
/// List of extra topics to initially subscribe to as strings.
|
||||
pub topics: Vec<String>,
|
||||
/// Shard pubsub topic prefix.
|
||||
pub shard_prefix: String,
|
||||
/// The main beacon chain topic to subscribe to.
|
||||
pub beacon_chain_topic: String,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -41,8 +41,6 @@ impl Default for Config {
|
||||
boot_nodes: vec![],
|
||||
client_version: version::version(),
|
||||
topics: Vec::new(),
|
||||
beacon_chain_topic: String::from("beacon_chain"),
|
||||
shard_prefix: String::from("attestations"), // single topic for all attestation for the moment.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ pub mod rpc;
|
||||
mod service;
|
||||
|
||||
pub use behaviour::PubsubMessage;
|
||||
pub use config::Config as NetworkConfig;
|
||||
pub use config::{ChainType, Config as NetworkConfig, BEACON_PUBSUB_TOPIC, SHARD_TOPIC_PREFIX};
|
||||
pub use libp2p::floodsub::{Topic, TopicBuilder, TopicHash};
|
||||
pub use libp2p::multiaddr;
|
||||
pub use libp2p::Multiaddr;
|
||||
|
||||
@@ -4,6 +4,7 @@ use crate::multiaddr::Protocol;
|
||||
use crate::rpc::RPCEvent;
|
||||
use crate::NetworkConfig;
|
||||
use crate::{TopicBuilder, TopicHash};
|
||||
use crate::{BEACON_PUBSUB_TOPIC, SHARD_TOPIC_PREFIX};
|
||||
use futures::prelude::*;
|
||||
use futures::Stream;
|
||||
use libp2p::core::{
|
||||
@@ -88,8 +89,8 @@ impl Service {
|
||||
let mut topics = vec![];
|
||||
//TODO: Handle multiple shard attestations. For now we simply use a separate topic for
|
||||
//attestations
|
||||
topics.push(config.shard_prefix);
|
||||
topics.push(config.beacon_chain_topic);
|
||||
topics.push(SHARD_TOPIC_PREFIX.to_string());
|
||||
topics.push(BEACON_PUBSUB_TOPIC.to_string());
|
||||
|
||||
topics.append(&mut config.topics.clone());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user