Skip to content

Commit

Permalink
- The chain metadata service keeps an internal copy of the chain meta…
Browse files Browse the repository at this point in the history
…data that it distributes to remote nodes. It should keep this copy uptodate with the blockchain db based on received BlockEvents. It only updated the metadata on block add events and not reorg events, this could have resulted in outdated metadata being shared on the network.

- Fixed an issue with the chain metadata service where it was not updating its copy of the chain metadata on reorg events. This could have resulted in some nodes on the network reporting outdated chain metadata.
- The chain metadata service will look for both block add and reorg events to determine if the blockchain db state was updated and the latest chain metadata needs to be retrieved.
- Also, chained the max send retries used by the Message protocol to 1.
  • Loading branch information
Yuko Roodt committed May 19, 2020
1 parent 824dfe0 commit bb3ada5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use super::{error::ChainMetadataSyncError, LOG_TARGET};
use crate::{
base_node::{
chain_metadata_service::handle::{ChainMetadataEvent, PeerChainMetadata},
comms_interface::{BlockEvent, Broadcast, LocalNodeCommsInterface},
comms_interface::{BlockEvent, LocalNodeCommsInterface},
proto,
},
chain_storage::BlockAddResult,
Expand Down Expand Up @@ -109,9 +109,9 @@ impl ChainMetadataService {

/// Handle BlockEvents
async fn handle_block_event(&mut self, event: &BlockEvent) -> Result<(), ChainMetadataSyncError> {
let _broadcast = Broadcast::from(true);
match event {
BlockEvent::Verified((_, BlockAddResult::Ok, _broadcast)) => {
BlockEvent::Verified((_, BlockAddResult::Ok, _)) |
BlockEvent::Verified((_, BlockAddResult::ChainReorg(_), _)) => {
self.update_liveness_chain_metadata().await?;
},
BlockEvent::Verified(_) | BlockEvent::Invalid(_) => {},
Expand Down
2 changes: 1 addition & 1 deletion comms/src/builder/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ pub const MESSAGING_EVENTS_BUFFER_SIZE: usize = 100;
pub const MESSAGING_REQUEST_BUFFER_SIZE: usize = 50;
/// The default maximum number of times to retry sending a failed message before publishing a SendMessageFailed event.
/// This can be low because dialing a peer is already attempted a number of times.
pub const MESSAGING_MAX_SEND_RETRIES: usize = 2;
pub const MESSAGING_MAX_SEND_RETRIES: usize = 1;

0 comments on commit bb3ada5

Please sign in to comment.