Tidy up stale connections. (#406)

* If messageId changes and network ID doesn't, remove 'old' message_id

* Boot nodes/connection when no recent messages received for it

* Separate task needed for soketto recv to avoid cancel-safety issues with new interval

* Wee tidy up

* cargo fmt

* Add some logging around node adding/removing

* Another log info msg

* a bit of tidy up

* bump stale node timeout to 60s
This commit is contained in:
James Wilson
2021-09-21 15:49:42 +01:00
committed by GitHub
parent 0bf1968fa3
commit b4b128f9fe
9 changed files with 142 additions and 46 deletions
+2 -1
View File
@@ -141,6 +141,7 @@ impl Payload {
#[cfg(test)]
mod tests {
use super::*;
use arrayvec::ArrayString;
use bincode::Options;
// Without adding a derive macro and marker trait (and enforcing their use), we don't really
@@ -166,7 +167,7 @@ mod tests {
implementation: "foo".into(),
version: "foo".into(),
validator: None,
network_id: None,
network_id: ArrayString::new(),
startup_time: None,
},
}),
+3 -1
View File
@@ -17,6 +17,7 @@
//! These types are partly used in [`crate::node_message`], but also stored and used
//! more generally through the application.
use arrayvec::ArrayString;
use serde::ser::{SerializeTuple, Serializer};
use serde::{Deserialize, Serialize};
@@ -25,6 +26,7 @@ use crate::{time, MeanList};
pub type BlockNumber = u64;
pub type Timestamp = u64;
pub use primitive_types::H256 as BlockHash;
pub type NetworkId = ArrayString<64>;
/// Basic node details.
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -34,7 +36,7 @@ pub struct NodeDetails {
pub implementation: Box<str>,
pub version: Box<str>,
pub validator: Option<Box<str>>,
pub network_id: Option<Box<str>>,
pub network_id: NetworkId,
pub startup_time: Option<Box<str>>,
}