Remove broken "Consensus" tab from UI and related code (#434)

* Remove consensus-tab related stuff, and unused messages, from the telemetry backend

* also remove AfgAuthoritySet feed message, and handle same from node

* Blat everything consensus related that I can find in the UI

* cargo fmt

* README: had -> has

Co-authored-by: David <dvdplm@gmail.com>

Co-authored-by: David <dvdplm@gmail.com>
This commit is contained in:
James Wilson
2021-11-25 12:34:36 +00:00
committed by GitHub
parent 73a4cf29b9
commit 17432d712f
26 changed files with 57 additions and 2021 deletions
+9 -51
View File
@@ -15,8 +15,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use common::node_message::Payload;
use common::node_types::BlockHash;
use common::node_types::{Block, Timestamp};
use common::node_types::{BlockHash, BlockNumber};
use common::{id_type, time, DenseMap, MostSeen, NumStats};
use once_cell::sync::Lazy;
use std::collections::HashSet;
@@ -149,13 +149,12 @@ impl Chain {
}
/// Attempt to update the best block seen in this chain.
/// Returns a boolean which denotes whether the output is for finalization feeds (true) or not (false).
pub fn update_node(
&mut self,
nid: ChainNodeId,
payload: Payload,
feed: &mut FeedMessageSerializer,
) -> bool {
) {
if let Some(block) = payload.best_block() {
self.handle_block(block, nid, feed);
}
@@ -163,65 +162,26 @@ impl Chain {
if let Some(node) = self.nodes.get_mut(nid) {
match payload {
Payload::SystemInterval(ref interval) => {
// Send a feed message if any of the relevant node details change:
if node.update_hardware(interval) {
feed.push(feed_message::Hardware(nid.into(), node.hardware()));
}
if let Some(stats) = node.update_stats(interval) {
feed.push(feed_message::NodeStatsUpdate(nid.into(), stats));
}
if let Some(io) = node.update_io(interval) {
feed.push(feed_message::NodeIOUpdate(nid.into(), io));
}
}
Payload::AfgAuthoritySet(authority) => {
node.set_validator_address(authority.authority_id.clone());
return false;
}
Payload::AfgFinalized(finalized) => {
if let Ok(finalized_number) = finalized.finalized_number.parse::<BlockNumber>()
{
if let Some(addr) = node.details().validator.clone() {
feed.push(feed_message::AfgFinalized(
addr,
finalized_number,
finalized.finalized_hash,
));
}
// If our node validator address (and thus details) change, send an
// updated "add node" feed message:
if node.set_validator_address(authority.authority_id.clone()) {
feed.push(feed_message::AddedNode(nid.into(), &node));
}
return true;
return;
}
Payload::AfgReceivedPrecommit(precommit) => {
if let Ok(finalized_number) = precommit.target_number.parse::<BlockNumber>() {
if let Some(addr) = node.details().validator.clone() {
let voter = precommit.voter.clone();
feed.push(feed_message::AfgReceivedPrecommit(
addr,
finalized_number,
precommit.target_hash,
voter,
));
}
}
return true;
}
Payload::AfgReceivedPrevote(prevote) => {
if let Ok(finalized_number) = prevote.target_number.parse::<BlockNumber>() {
if let Some(addr) = node.details().validator.clone() {
let voter = prevote.voter.clone();
feed.push(feed_message::AfgReceivedPrevote(
addr,
finalized_number,
prevote.target_hash,
voter,
));
}
}
return true;
}
Payload::AfgReceivedCommit(_) => {}
_ => (),
_ => {}
}
if let Some(block) = payload.finalized_block() {
@@ -242,8 +202,6 @@ impl Chain {
}
}
}
false
}
fn handle_block(&mut self, block: &Block, nid: ChainNodeId, feed: &mut FeedMessageSerializer) {
+7 -2
View File
@@ -213,8 +213,13 @@ impl Node {
self.stale
}
pub fn set_validator_address(&mut self, addr: Box<str>) {
self.details.validator = Some(addr);
pub fn set_validator_address(&mut self, addr: Box<str>) -> bool {
if self.details.validator.as_ref() == Some(&addr) {
false
} else {
self.details.validator = Some(addr);
true
}
}
pub fn startup_time(&self) -> Option<Timestamp> {
+2 -3
View File
@@ -213,18 +213,17 @@ impl State {
}
/// Attempt to update the best block seen, given a node and block.
/// Returns a boolean which denotes whether the output is for finalization feeds (true) or not (false).
pub fn update_node(
&mut self,
NodeId(chain_id, chain_node_id): NodeId,
payload: Payload,
feed: &mut FeedMessageSerializer,
) -> bool {
) {
let chain = match self.chains.get_mut(chain_id) {
Some(chain) => chain,
None => {
log::error!("Cannot find chain for node with ID {:?}", chain_id);
return false;
return;
}
};