mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-04-22 05:38:00 +00:00
Appease Clippy
This commit is contained in:
@@ -79,10 +79,8 @@ impl Chain {
|
||||
|
||||
if &*self.label.0 == label {
|
||||
self.label.1 += 1;
|
||||
} else {
|
||||
if count > self.label.1 {
|
||||
self.rename(label.into(), count);
|
||||
}
|
||||
} else if count > self.label.1 {
|
||||
self.rename(label.into(), count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +170,7 @@ impl Chain {
|
||||
self.block_times.reset();
|
||||
self.timestamp = timestamp;
|
||||
|
||||
self.serializer.push(feed::BestBlock(self.best.height, timestamp.unwrap_or_else(|| now), None));
|
||||
self.serializer.push(feed::BestBlock(self.best.height, timestamp.unwrap_or(now), None));
|
||||
self.serializer.push(feed::BestFinalized(finalized.height, finalized.hash));
|
||||
}
|
||||
}
|
||||
@@ -259,7 +257,7 @@ impl Handler<AddNode> for Chain {
|
||||
let nid = self.nodes.add(Node::new(node));
|
||||
let chain = ctx.address();
|
||||
|
||||
if let Err(_) = rec.do_send(Initialize { nid, conn_id, chain }) {
|
||||
if rec.do_send(Initialize { nid, conn_id, chain }).is_err() {
|
||||
self.nodes.remove(nid);
|
||||
} else if let Some(node) = self.nodes.get(nid) {
|
||||
self.serializer.push(feed::AddedNode(nid, node));
|
||||
@@ -456,7 +454,7 @@ impl Handler<Subscribe> for Chain {
|
||||
self.serializer.push(feed::TimeSync(now()));
|
||||
self.serializer.push(feed::BestBlock(
|
||||
self.best.height,
|
||||
self.timestamp.unwrap_or_else(|| 0),
|
||||
self.timestamp.unwrap_or(0),
|
||||
self.average_block_time,
|
||||
));
|
||||
self.serializer.push(feed::BestFinalized(self.finalized.height, self.finalized.hash));
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ impl FeedMessageSerializer {
|
||||
}
|
||||
|
||||
pub fn finalize(&mut self) -> Option<Serialized> {
|
||||
if self.buffer.len() == 0 {
|
||||
if self.buffer.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
+9
-8
@@ -20,10 +20,10 @@ use node::connector::NodeConnector;
|
||||
use types::NodeId;
|
||||
use util::{Locator, LocatorFactory};
|
||||
|
||||
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||
const AUTHORS: &'static str = env!("CARGO_PKG_AUTHORS");
|
||||
const NAME: &'static str = "Substrate Telemetry Backend";
|
||||
const ABOUT: &'static str = "This is the Telemetry Backend that injects and provide the data sent by Substrate/Polkadot nodes";
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
const AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
|
||||
const NAME: &str = "Substrate Telemetry Backend";
|
||||
const ABOUT: &str = "This is the Telemetry Backend that injects and provide the data sent by Substrate/Polkadot nodes";
|
||||
|
||||
#[derive(Clap)]
|
||||
#[clap(name = NAME, version = VERSION, author = AUTHORS, about = ABOUT)]
|
||||
@@ -54,9 +54,9 @@ enum LogLevel {
|
||||
Trace,
|
||||
}
|
||||
|
||||
impl Into<log::LevelFilter> for &LogLevel {
|
||||
fn into(self) -> log::LevelFilter {
|
||||
match self {
|
||||
impl From<&LogLevel> for log::LevelFilter {
|
||||
fn from(log_level: &LogLevel) -> Self {
|
||||
match log_level {
|
||||
LogLevel::Error => log::LevelFilter::Error,
|
||||
LogLevel::Warn => log::LevelFilter::Warn,
|
||||
LogLevel::Info => log::LevelFilter::Info,
|
||||
@@ -65,6 +65,7 @@ impl Into<log::LevelFilter> for &LogLevel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Entry point for connecting nodes
|
||||
#[get("/submit/")]
|
||||
async fn node_route(
|
||||
@@ -74,7 +75,7 @@ async fn node_route(
|
||||
locator: web::Data<Addr<Locator>>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let ip = req.connection_info().realip_remote_addr().and_then(|mut addr| {
|
||||
if let Some(port_idx) = addr.find(":") {
|
||||
if let Some(port_idx) = addr.find(':') {
|
||||
addr = &addr[..port_idx];
|
||||
}
|
||||
addr.parse::<Ipv4Addr>().ok()
|
||||
|
||||
+1
-4
@@ -89,10 +89,7 @@ impl Node {
|
||||
}
|
||||
|
||||
pub fn location(&self) -> Option<&NodeLocation> {
|
||||
match self.location {
|
||||
Some(ref location) => Some(&**location),
|
||||
None => None
|
||||
}
|
||||
self.location.as_deref()
|
||||
}
|
||||
|
||||
pub fn update_location(&mut self, location: Arc<NodeLocation>) {
|
||||
|
||||
@@ -118,7 +118,7 @@ impl NodeConnector {
|
||||
_ => (),
|
||||
}
|
||||
|
||||
self.aggregator.do_send(AddNode { rec, conn_id, node });
|
||||
self.aggregator.do_send(AddNode { node, conn_id, rec });
|
||||
} else {
|
||||
if backlog.len() >= 10 {
|
||||
backlog.remove(0);
|
||||
|
||||
@@ -26,7 +26,7 @@ impl LocatorFactory {
|
||||
// Default entry for localhost
|
||||
cache.insert(
|
||||
Ipv4Addr::new(127, 0, 0, 1),
|
||||
Some(Arc::new(NodeLocation { latitude: 52.5166667, longitude: 13.4, city: "Berlin".into() })),
|
||||
Some(Arc::new(NodeLocation { latitude: 52.516_6667, longitude: 13.4, city: "Berlin".into() })),
|
||||
);
|
||||
|
||||
LocatorFactory {
|
||||
@@ -64,7 +64,7 @@ impl IPApiLocate {
|
||||
fn into_node_location(self) -> Option<NodeLocation> {
|
||||
let IPApiLocate { city, loc } = self;
|
||||
|
||||
let mut loc = loc.split(",").map(|n| n.parse());
|
||||
let mut loc = loc.split(',').map(|n| n.parse());
|
||||
|
||||
let latitude = loc.next()?.ok()?;
|
||||
let longitude = loc.next()?.ok()?;
|
||||
@@ -176,4 +176,4 @@ mod tests {
|
||||
|
||||
assert!(location.is_none());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user