Move a bunch of things around and flatten common crate

This commit is contained in:
James Wilson
2021-06-30 17:27:10 +01:00
parent 4308359feb
commit f7ab3292c2
21 changed files with 217 additions and 228 deletions
@@ -4,9 +4,9 @@ use common::{
ShardNodeId,
MuteReason
},
types::BlockHash,
node,
util::now
node_types::BlockHash,
node_message,
time
};
use bimap::BiMap;
use std::{net::{IpAddr, Ipv4Addr}, str::FromStr};
@@ -38,13 +38,13 @@ pub enum FromShardWebsocket {
Add {
local_id: ShardNodeId,
ip: Option<std::net::IpAddr>,
node: common::types::NodeDetails,
genesis_hash: common::types::BlockHash
node: common::node_types::NodeDetails,
genesis_hash: common::node_types::BlockHash
},
/// Update/pass through details about a node.
Update {
local_id: ShardNodeId,
payload: node::Payload
payload: node_message::Payload
},
/// Tell the aggregator that a node has been removed when it disconnects.
Remove {
@@ -379,7 +379,7 @@ impl InnerLoop {
feed_serializer.push(feed_message::UnsubscribedFrom(old_chain.label()));
}
feed_serializer.push(feed_message::SubscribedTo(new_chain.label()));
feed_serializer.push(feed_message::TimeSync(now()));
feed_serializer.push(feed_message::TimeSync(time::now()));
feed_serializer.push(feed_message::BestBlock (
new_chain.best_block().height,
new_chain.timestamp(),
+1 -1
View File
@@ -6,7 +6,7 @@ use std::mem;
use crate::state::Node;
use serde_json::to_writer;
use common::types::{
use common::node_types::{
BlockDetails, BlockHash, BlockNumber, NodeHardware, NodeIO, NodeStats,
Timestamp
};
+1 -1
View File
@@ -7,7 +7,7 @@ use serde::Deserialize;
use futures::{Sink, SinkExt, StreamExt};
use futures::channel::mpsc;
use common::types::NodeLocation;
use common::node_types::NodeLocation;
use tokio::sync::Semaphore;
/// The returned location is optional; it may be None if not found.
+1 -2
View File
@@ -7,13 +7,12 @@ use std::net::SocketAddr;
use std::str::FromStr;
use bincode::Options;
use common::internal_messages;
use structopt::StructOpt;
use simple_logger::SimpleLogger;
use futures::{StreamExt, SinkExt, channel::mpsc};
use warp::Filter;
use warp::filters::ws;
use common::{log_level::LogLevel};
use common::{ internal_messages, LogLevel };
use aggregator::{ Aggregator, FromFeedWebsocket, ToFeedWebsocket, FromShardWebsocket, ToShardWebsocket };
const VERSION: &str = env!("CARGO_PKG_VERSION");
+5 -7
View File
@@ -1,11 +1,9 @@
use std::collections::{ HashSet };
use common::types::{ BlockHash, BlockNumber };
use common::types::{Block, Timestamp};
use common::util::{now, DenseMap, NumStats};
use common::most_seen::MostSeen;
use common::node::Payload;
use common::node_types::{ BlockHash, BlockNumber };
use common::node_types::{Block, Timestamp};
use common::node_message::Payload;
use common::{time, id_type, DenseMap, MostSeen, NumStats};
use once_cell::sync::Lazy;
use common::id_type;
use crate::feed_message::{self, FeedMessageSerializer};
use crate::find_location;
@@ -217,7 +215,7 @@ impl Chain {
fn handle_block(&mut self, block: &Block, nid: ChainNodeId, feed: &mut FeedMessageSerializer) {
let mut propagation_time = None;
let now = now();
let now = time::now();
let nodes_len = self.nodes.len();
self.update_stale_nodes(now, feed);
+4 -4
View File
@@ -1,9 +1,9 @@
use common::types::{
use common::node_types::{
Block, BlockDetails, NodeDetails, NodeHardware, NodeIO, NodeLocation, NodeStats,
Timestamp,
};
use common::util::now;
use common::node::SystemInterval;
use common::time;
use common::node_message::SystemInterval;
use crate::find_location;
/// Minimum time between block below broadcasting updates to the browser gets throttled, in ms.
@@ -135,7 +135,7 @@ impl Node {
if let Some(download) = interval.bandwidth_download {
changed |= self.hardware.download.push(download);
}
self.hardware.chart_stamps.push(now() as f64);
self.hardware.chart_stamps.push(time::now() as f64);
changed
}
+3 -5
View File
@@ -1,13 +1,11 @@
use std::collections::{ HashSet, HashMap };
use common::types::{ BlockHash };
use super::node::Node;
use common::types::{Block, NodeDetails, Timestamp};
use common::util::{DenseMap};
use common::node::Payload;
use common::node_types::{Block, BlockHash, NodeDetails, Timestamp};
use common::node_message::Payload;
use common::{ id_type, DenseMap };
use std::iter::IntoIterator;
use crate::feed_message::FeedMessageSerializer;
use crate::find_location;
use common::id_type;
use super::chain::{ self, Chain, ChainNodeId };