mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Simplify DandelionConfig (#1115)
* Simplify DandelionConfig and make fields optional
This commit is contained in:
parent
68c7cff6db
commit
d6b689bada
11 changed files with 73 additions and 127 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -698,6 +698,7 @@ dependencies = [
|
||||||
"bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_core 0.2.0",
|
"grin_core 0.2.0",
|
||||||
|
"grin_pool 0.2.0",
|
||||||
"grin_store 0.2.0",
|
"grin_store 0.2.0",
|
||||||
"grin_util 0.2.0",
|
"grin_util 0.2.0",
|
||||||
"net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -20,3 +20,6 @@ time = "0.1"
|
||||||
grin_core = { path = "../core" }
|
grin_core = { path = "../core" }
|
||||||
grin_store = { path = "../store" }
|
grin_store = { path = "../store" }
|
||||||
grin_util = { path = "../util" }
|
grin_util = { path = "../util" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
grin_pool = { path = "../pool" }
|
||||||
|
|
|
@ -53,6 +53,5 @@ pub use peer::Peer;
|
||||||
pub use peers::Peers;
|
pub use peers::Peers;
|
||||||
pub use serv::{DummyAdapter, Server};
|
pub use serv::{DummyAdapter, Server};
|
||||||
pub use store::{PeerData, State};
|
pub use store::{PeerData, State};
|
||||||
pub use types::{Capabilities, ChainAdapter, DandelionConfig, Direction, Error, P2PConfig,
|
pub use types::{Capabilities, ChainAdapter, Direction, Error, P2PConfig, PeerInfo, ReasonForBan,
|
||||||
PeerInfo, ReasonForBan, TxHashSetRead, MAX_BLOCK_HEADERS, MAX_LOCATORS,
|
TxHashSetRead, MAX_BLOCK_HEADERS, MAX_LOCATORS, MAX_PEER_ADDRS};
|
||||||
MAX_PEER_ADDRS};
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ use util::LOGGER;
|
||||||
/// peers, receiving connections from other peers and keep track of all of them.
|
/// peers, receiving connections from other peers and keep track of all of them.
|
||||||
pub struct Server {
|
pub struct Server {
|
||||||
pub config: P2PConfig,
|
pub config: P2PConfig,
|
||||||
pub dandelion_config: DandelionConfig,
|
|
||||||
capabilities: Capabilities,
|
capabilities: Capabilities,
|
||||||
handshake: Arc<Handshake>,
|
handshake: Arc<Handshake>,
|
||||||
pub peers: Arc<Peers>,
|
pub peers: Arc<Peers>,
|
||||||
|
@ -51,7 +50,6 @@ impl Server {
|
||||||
db_root: String,
|
db_root: String,
|
||||||
mut capab: Capabilities,
|
mut capab: Capabilities,
|
||||||
config: P2PConfig,
|
config: P2PConfig,
|
||||||
dandelion_config: DandelionConfig,
|
|
||||||
adapter: Arc<ChainAdapter>,
|
adapter: Arc<ChainAdapter>,
|
||||||
genesis: Hash,
|
genesis: Hash,
|
||||||
stop: Arc<AtomicBool>,
|
stop: Arc<AtomicBool>,
|
||||||
|
@ -81,7 +79,6 @@ impl Server {
|
||||||
}
|
}
|
||||||
Ok(Server {
|
Ok(Server {
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
dandelion_config: dandelion_config.clone(),
|
|
||||||
capabilities: capab,
|
capabilities: capab,
|
||||||
handshake: Arc::new(Handshake::new(genesis, config.clone())),
|
handshake: Arc::new(Handshake::new(genesis, config.clone())),
|
||||||
peers: Arc::new(Peers::new(PeerStore::new(db_root)?, adapter, config)),
|
peers: Arc::new(Peers::new(PeerStore::new(db_root)?, adapter, config)),
|
||||||
|
|
|
@ -90,23 +90,6 @@ impl<T> From<mpsc::TrySendError<T>> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration for "Dandelion".
|
|
||||||
/// Note: shared between p2p and pool.
|
|
||||||
/// Look in top-level server config for info on configuring these parameters.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct DandelionConfig {
|
|
||||||
/// Choose new Dandelion relay peer every n secs.
|
|
||||||
pub relay_secs: u64,
|
|
||||||
/// Dandelion embargo, fluff and broadcast tx if not seen on network before
|
|
||||||
/// embargo expires.
|
|
||||||
pub embargo_secs: u64,
|
|
||||||
/// Dandelion patience timer, fluff/stem processing runs every n secs.
|
|
||||||
/// Tx aggregation happens on stem txs received within this window.
|
|
||||||
pub patience_secs: u64,
|
|
||||||
/// Dandelion stem probability (stem 90% of the time, fluff 10% etc.)
|
|
||||||
pub stem_probability: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Configuration for the peer-to-peer server.
|
/// Configuration for the peer-to-peer server.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct P2PConfig {
|
pub struct P2PConfig {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
extern crate grin_core as core;
|
extern crate grin_core as core;
|
||||||
extern crate grin_p2p as p2p;
|
extern crate grin_p2p as p2p;
|
||||||
|
extern crate grin_pool as pool;
|
||||||
extern crate grin_util as util;
|
extern crate grin_util as util;
|
||||||
|
|
||||||
use std::net::{SocketAddr, TcpListener, TcpStream};
|
use std::net::{SocketAddr, TcpListener, TcpStream};
|
||||||
|
@ -25,6 +26,7 @@ use std::time;
|
||||||
use core::core::hash::Hash;
|
use core::core::hash::Hash;
|
||||||
use core::core::target::Difficulty;
|
use core::core::target::Difficulty;
|
||||||
use p2p::Peer;
|
use p2p::Peer;
|
||||||
|
use pool::DandelionConfig;
|
||||||
|
|
||||||
fn open_port() -> u16 {
|
fn open_port() -> u16 {
|
||||||
// use port 0 to allow the OS to assign an open port
|
// use port 0 to allow the OS to assign an open port
|
||||||
|
@ -47,11 +49,11 @@ fn peer_handshake() {
|
||||||
peers_deny: None,
|
peers_deny: None,
|
||||||
..p2p::P2PConfig::default()
|
..p2p::P2PConfig::default()
|
||||||
};
|
};
|
||||||
let dandelion_config = p2p::DandelionConfig {
|
let dandelion_config = pool::DandelionConfig {
|
||||||
relay_secs: 600,
|
relay_secs: Some(600),
|
||||||
embargo_secs: 30,
|
embargo_secs: Some(30),
|
||||||
patience_secs: 10,
|
patience_secs: Some(10),
|
||||||
stem_probability: 90,
|
stem_probability: Some(90),
|
||||||
};
|
};
|
||||||
let net_adapter = Arc::new(p2p::DummyAdapter {});
|
let net_adapter = Arc::new(p2p::DummyAdapter {});
|
||||||
let server = Arc::new(
|
let server = Arc::new(
|
||||||
|
@ -59,7 +61,6 @@ fn peer_handshake() {
|
||||||
".grin".to_owned(),
|
".grin".to_owned(),
|
||||||
p2p::Capabilities::UNKNOWN,
|
p2p::Capabilities::UNKNOWN,
|
||||||
p2p_config.clone(),
|
p2p_config.clone(),
|
||||||
dandelion_config.clone(),
|
|
||||||
net_adapter.clone(),
|
net_adapter.clone(),
|
||||||
Hash::from_vec(&vec![]),
|
Hash::from_vec(&vec![]),
|
||||||
Arc::new(AtomicBool::new(false)),
|
Arc::new(AtomicBool::new(false)),
|
||||||
|
|
|
@ -22,21 +22,63 @@ use core::consensus;
|
||||||
use core::core::transaction;
|
use core::core::transaction;
|
||||||
use core::core::transaction::Transaction;
|
use core::core::transaction::Transaction;
|
||||||
|
|
||||||
|
/// Dandelion relay timer
|
||||||
|
const DANDELION_RELAY_SECS: u64 = 600;
|
||||||
|
|
||||||
|
/// Dandelion emabargo timer
|
||||||
|
const DANDELION_EMBARGO_SECS: u64 = 180;
|
||||||
|
|
||||||
|
/// Dandelion patience timer
|
||||||
|
const DANDELION_PATIENCE_SECS: u64 = 10;
|
||||||
|
|
||||||
|
/// Dandelion stem probability (stem 90% of the time, fluff 10%).
|
||||||
|
const DANDELION_STEM_PROBABILITY: usize = 90;
|
||||||
|
|
||||||
/// Configuration for "Dandelion".
|
/// Configuration for "Dandelion".
|
||||||
/// Note: shared between p2p and pool.
|
/// Note: shared between p2p and pool.
|
||||||
/// Look in top-level server config for info on configuring these parameters.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct DandelionConfig {
|
pub struct DandelionConfig {
|
||||||
/// Choose new Dandelion relay peer every n secs.
|
/// Choose new Dandelion relay peer every n secs.
|
||||||
pub relay_secs: u64,
|
#[serde = "default_dandelion_relay_secs"]
|
||||||
|
pub relay_secs: Option<u64>,
|
||||||
/// Dandelion embargo, fluff and broadcast tx if not seen on network before
|
/// Dandelion embargo, fluff and broadcast tx if not seen on network before
|
||||||
/// embargo expires.
|
/// embargo expires.
|
||||||
pub embargo_secs: u64,
|
#[serde = "default_dandelion_embargo_secs"]
|
||||||
|
pub embargo_secs: Option<u64>,
|
||||||
/// Dandelion patience timer, fluff/stem processing runs every n secs.
|
/// Dandelion patience timer, fluff/stem processing runs every n secs.
|
||||||
/// Tx aggregation happens on stem txs received within this window.
|
/// Tx aggregation happens on stem txs received within this window.
|
||||||
pub patience_secs: u64,
|
#[serde = "default_dandelion_patience_secs"]
|
||||||
|
pub patience_secs: Option<u64>,
|
||||||
/// Dandelion stem probability (stem 90% of the time, fluff 10% etc.)
|
/// Dandelion stem probability (stem 90% of the time, fluff 10% etc.)
|
||||||
pub stem_probability: usize,
|
#[serde = "default_dandelion_stem_probability"]
|
||||||
|
pub stem_probability: Option<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DandelionConfig {
|
||||||
|
fn default() -> DandelionConfig {
|
||||||
|
DandelionConfig {
|
||||||
|
relay_secs: default_dandelion_relay_secs(),
|
||||||
|
embargo_secs: default_dandelion_embargo_secs(),
|
||||||
|
patience_secs: default_dandelion_patience_secs(),
|
||||||
|
stem_probability: default_dandelion_stem_probability(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_dandelion_relay_secs() -> Option<u64> {
|
||||||
|
Some(DANDELION_RELAY_SECS)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_dandelion_embargo_secs() -> Option<u64> {
|
||||||
|
Some(DANDELION_EMBARGO_SECS)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_dandelion_patience_secs() -> Option<u64> {
|
||||||
|
Some(DANDELION_PATIENCE_SECS)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_dandelion_stem_probability() -> Option<usize> {
|
||||||
|
Some(DANDELION_STEM_PROBABILITY)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transaction pool configuration
|
/// Transaction pool configuration
|
||||||
|
|
|
@ -26,18 +26,6 @@ use pool;
|
||||||
use store;
|
use store;
|
||||||
use wallet;
|
use wallet;
|
||||||
|
|
||||||
/// Dandelion relay timer
|
|
||||||
const DANDELION_RELAY_SECS: u64 = 600;
|
|
||||||
|
|
||||||
/// Dandelion emabargo timer
|
|
||||||
const DANDELION_EMBARGO_SECS: u64 = 180;
|
|
||||||
|
|
||||||
/// Dandelion patience timer
|
|
||||||
const DANDELION_PATIENCE_SECS: u64 = 10;
|
|
||||||
|
|
||||||
/// Dandelion stem probability (stem 90% of the time, fluff 10%).
|
|
||||||
const DANDELION_STEM_PROBABILITY: usize = 90;
|
|
||||||
|
|
||||||
/// Error type wrapping underlying module errors.
|
/// Error type wrapping underlying module errors.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
@ -135,54 +123,6 @@ impl Default for Seeding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_dandelion_stem_probability() -> usize {
|
|
||||||
DANDELION_STEM_PROBABILITY
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_dandelion_relay_secs() -> u64 {
|
|
||||||
DANDELION_RELAY_SECS
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_dandelion_embargo_secs() -> u64 {
|
|
||||||
DANDELION_EMBARGO_SECS
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_dandelion_patience_secs() -> u64 {
|
|
||||||
DANDELION_PATIENCE_SECS
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Dandelion config.
|
|
||||||
/// Note: Used by both p2p and pool components.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct DandelionConfig {
|
|
||||||
/// Choose new Dandelion relay peer every n secs.
|
|
||||||
#[serde = "default_dandelion_relay_secs"]
|
|
||||||
pub relay_secs: u64,
|
|
||||||
/// Dandelion embargo, fluff and broadcast tx if not seen on network before
|
|
||||||
/// embargo expires.
|
|
||||||
#[serde = "default_dandelion_embargo_secs"]
|
|
||||||
pub embargo_secs: u64,
|
|
||||||
/// Dandelion patience timer, fluff/stem processing runs every n secs.
|
|
||||||
/// Tx aggregation happens on stem txs received within this window.
|
|
||||||
#[serde = "default_dandelion_patience_secs"]
|
|
||||||
pub patience_secs: u64,
|
|
||||||
/// Dandelion stem probability.
|
|
||||||
#[serde = "default_dandelion_stem_probability"]
|
|
||||||
pub stem_probability: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Default address for peer-to-peer connections.
|
|
||||||
impl Default for DandelionConfig {
|
|
||||||
fn default() -> DandelionConfig {
|
|
||||||
DandelionConfig {
|
|
||||||
relay_secs: default_dandelion_relay_secs(),
|
|
||||||
embargo_secs: default_dandelion_embargo_secs(),
|
|
||||||
patience_secs: default_dandelion_patience_secs(),
|
|
||||||
stem_probability: default_dandelion_stem_probability(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Full server configuration, aggregating configurations required for the
|
/// Full server configuration, aggregating configurations required for the
|
||||||
/// different components.
|
/// different components.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -229,7 +169,7 @@ pub struct ServerConfig {
|
||||||
|
|
||||||
/// Dandelion configuration
|
/// Dandelion configuration
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub dandelion_config: DandelionConfig,
|
pub dandelion_config: pool::DandelionConfig,
|
||||||
|
|
||||||
/// Whether to skip the sync timeout on startup
|
/// Whether to skip the sync timeout on startup
|
||||||
/// (To assist testing on solo chains)
|
/// (To assist testing on solo chains)
|
||||||
|
@ -249,28 +189,6 @@ pub struct ServerConfig {
|
||||||
pub test_miner_wallet_url: Option<String>,
|
pub test_miner_wallet_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerConfig {
|
|
||||||
/// Adapter for configuring Dandelion on the pool component.
|
|
||||||
pub fn pool_dandelion_config(&self) -> pool::DandelionConfig {
|
|
||||||
pool::DandelionConfig {
|
|
||||||
relay_secs: self.dandelion_config.relay_secs,
|
|
||||||
embargo_secs: self.dandelion_config.embargo_secs,
|
|
||||||
patience_secs: self.dandelion_config.patience_secs,
|
|
||||||
stem_probability: self.dandelion_config.stem_probability,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adapter for configuring Dandelion on the p2p component.
|
|
||||||
pub fn p2p_dandelion_config(&self) -> p2p::DandelionConfig {
|
|
||||||
p2p::DandelionConfig {
|
|
||||||
relay_secs: self.dandelion_config.relay_secs,
|
|
||||||
embargo_secs: self.dandelion_config.embargo_secs,
|
|
||||||
patience_secs: self.dandelion_config.patience_secs,
|
|
||||||
stem_probability: self.dandelion_config.stem_probability,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ServerConfig {
|
impl Default for ServerConfig {
|
||||||
fn default() -> ServerConfig {
|
fn default() -> ServerConfig {
|
||||||
ServerConfig {
|
ServerConfig {
|
||||||
|
@ -280,7 +198,7 @@ impl Default for ServerConfig {
|
||||||
seeding_type: Seeding::default(),
|
seeding_type: Seeding::default(),
|
||||||
seeds: None,
|
seeds: None,
|
||||||
p2p_config: p2p::P2PConfig::default(),
|
p2p_config: p2p::P2PConfig::default(),
|
||||||
dandelion_config: DandelionConfig::default(),
|
dandelion_config: pool::DandelionConfig::default(),
|
||||||
stratum_mining_config: Some(StratumServerConfig::default()),
|
stratum_mining_config: Some(StratumServerConfig::default()),
|
||||||
chain_type: ChainTypes::default(),
|
chain_type: ChainTypes::default(),
|
||||||
archive_mode: None,
|
archive_mode: None,
|
||||||
|
|
|
@ -22,7 +22,7 @@ use time::now_utc;
|
||||||
|
|
||||||
use core::core::hash::Hashed;
|
use core::core::hash::Hashed;
|
||||||
use core::core::transaction;
|
use core::core::transaction;
|
||||||
use p2p::DandelionConfig;
|
use pool::DandelionConfig;
|
||||||
use pool::{BlockChain, PoolEntryState, PoolError, TransactionPool, TxSource};
|
use pool::{BlockChain, PoolEntryState, PoolError, TransactionPool, TxSource};
|
||||||
use util::LOGGER;
|
use util::LOGGER;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pub fn monitor_transactions<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the patience timer, we loop every n secs.
|
// This is the patience timer, we loop every n secs.
|
||||||
let patience_secs = dandelion_config.patience_secs;
|
let patience_secs = dandelion_config.patience_secs.unwrap();
|
||||||
thread::sleep(Duration::from_secs(patience_secs));
|
thread::sleep(Duration::from_secs(patience_secs));
|
||||||
|
|
||||||
let tx_pool = tx_pool.clone();
|
let tx_pool = tx_pool.clone();
|
||||||
|
@ -185,7 +185,7 @@ where
|
||||||
|
|
||||||
for x in &mut fresh_entries.iter_mut() {
|
for x in &mut fresh_entries.iter_mut() {
|
||||||
let random = rng.gen_range(0, 101);
|
let random = rng.gen_range(0, 101);
|
||||||
if random <= dandelion_config.stem_probability {
|
if random <= dandelion_config.stem_probability.unwrap() {
|
||||||
x.state = PoolEntryState::ToStem;
|
x.state = PoolEntryState::ToStem;
|
||||||
} else {
|
} else {
|
||||||
x.state = PoolEntryState::ToFluff;
|
x.state = PoolEntryState::ToFluff;
|
||||||
|
@ -203,7 +203,7 @@ where
|
||||||
T: BlockChain + Send + Sync + 'static,
|
T: BlockChain + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let now = now_utc().to_timespec().sec;
|
let now = now_utc().to_timespec().sec;
|
||||||
let embargo_sec = dandelion_config.embargo_secs + rand::thread_rng().gen_range(0, 31);
|
let embargo_sec = dandelion_config.embargo_secs.unwrap() + rand::thread_rng().gen_range(0, 31);
|
||||||
let cutoff = now - embargo_sec as i64;
|
let cutoff = now - embargo_sec as i64;
|
||||||
|
|
||||||
let mut expired_entries = vec![];
|
let mut expired_entries = vec![];
|
||||||
|
|
|
@ -29,6 +29,7 @@ use time::{self, now_utc};
|
||||||
use hyper;
|
use hyper;
|
||||||
|
|
||||||
use p2p;
|
use p2p;
|
||||||
|
use pool::DandelionConfig;
|
||||||
use util::LOGGER;
|
use util::LOGGER;
|
||||||
|
|
||||||
const SEEDS_URL: &'static str = "http://grin-tech.org/seeds.txt";
|
const SEEDS_URL: &'static str = "http://grin-tech.org/seeds.txt";
|
||||||
|
@ -42,6 +43,7 @@ const DNS_SEEDS: &'static [&'static str] = &[
|
||||||
pub fn connect_and_monitor(
|
pub fn connect_and_monitor(
|
||||||
p2p_server: Arc<p2p::Server>,
|
p2p_server: Arc<p2p::Server>,
|
||||||
capabilities: p2p::Capabilities,
|
capabilities: p2p::Capabilities,
|
||||||
|
dandelion_config: DandelionConfig,
|
||||||
seed_list: Box<Fn() -> Vec<SocketAddr> + Send>,
|
seed_list: Box<Fn() -> Vec<SocketAddr> + Send>,
|
||||||
stop: Arc<AtomicBool>,
|
stop: Arc<AtomicBool>,
|
||||||
) {
|
) {
|
||||||
|
@ -73,7 +75,7 @@ pub fn connect_and_monitor(
|
||||||
tx.clone(),
|
tx.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
update_dandelion_relay(peers.clone(), p2p_server.dandelion_config.clone());
|
update_dandelion_relay(peers.clone(), dandelion_config.clone());
|
||||||
|
|
||||||
prev = current_time;
|
prev = current_time;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +161,7 @@ fn monitor_peers(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_dandelion_relay(peers: Arc<p2p::Peers>, dandelion_config: p2p::DandelionConfig) {
|
fn update_dandelion_relay(peers: Arc<p2p::Peers>, dandelion_config: DandelionConfig) {
|
||||||
// Dandelion Relay Updater
|
// Dandelion Relay Updater
|
||||||
let dandelion_relay = peers.get_dandelion_relay();
|
let dandelion_relay = peers.get_dandelion_relay();
|
||||||
if dandelion_relay.is_empty() {
|
if dandelion_relay.is_empty() {
|
||||||
|
@ -168,7 +170,7 @@ fn update_dandelion_relay(peers: Arc<p2p::Peers>, dandelion_config: p2p::Dandeli
|
||||||
} else {
|
} else {
|
||||||
for last_added in dandelion_relay.keys() {
|
for last_added in dandelion_relay.keys() {
|
||||||
let dandelion_interval = now_utc().to_timespec().sec - last_added;
|
let dandelion_interval = now_utc().to_timespec().sec - last_added;
|
||||||
if dandelion_interval >= dandelion_config.relay_secs as i64 {
|
if dandelion_interval >= dandelion_config.relay_secs.unwrap() as i64 {
|
||||||
debug!(LOGGER, "monitor_peers: updating expired dandelion relay");
|
debug!(LOGGER, "monitor_peers: updating expired dandelion relay");
|
||||||
peers.update_dandelion_relay();
|
peers.update_dandelion_relay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,6 @@ impl Server {
|
||||||
config.db_root.clone(),
|
config.db_root.clone(),
|
||||||
config.capabilities,
|
config.capabilities,
|
||||||
config.p2p_config.clone(),
|
config.p2p_config.clone(),
|
||||||
config.p2p_dandelion_config(),
|
|
||||||
net_adapter.clone(),
|
net_adapter.clone(),
|
||||||
genesis.hash(),
|
genesis.hash(),
|
||||||
stop.clone(),
|
stop.clone(),
|
||||||
|
@ -189,6 +188,7 @@ impl Server {
|
||||||
seed::connect_and_monitor(
|
seed::connect_and_monitor(
|
||||||
p2p_server.clone(),
|
p2p_server.clone(),
|
||||||
config.capabilities,
|
config.capabilities,
|
||||||
|
config.dandelion_config.clone(),
|
||||||
seeder,
|
seeder,
|
||||||
stop.clone(),
|
stop.clone(),
|
||||||
);
|
);
|
||||||
|
@ -232,7 +232,7 @@ impl Server {
|
||||||
"Starting dandelion monitor: {}", &config.api_http_addr
|
"Starting dandelion monitor: {}", &config.api_http_addr
|
||||||
);
|
);
|
||||||
dandelion_monitor::monitor_transactions(
|
dandelion_monitor::monitor_transactions(
|
||||||
config.p2p_dandelion_config(),
|
config.dandelion_config.clone(),
|
||||||
tx_pool.clone(),
|
tx_pool.clone(),
|
||||||
stop.clone(),
|
stop.clone(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue