Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix: avoid JoinsAllowed re-votes got filter out
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and Yoga07 committed Jun 16, 2021
1 parent f7bffe1 commit abc2531
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ qp2p = "~0.12.0"
rand = "~0.7.3"
rand_chacha = "~0.2.2"
resource_proof = "0.8.0"
sn_messaging = "36.0.1"
sn_messaging = "37.0.0"
sn_data_types = "~0.18.3"
thiserror = "1.0.23"
tokio = "1.3.0"
Expand Down
10 changes: 8 additions & 2 deletions src/routing/core/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use secured_linked_list::SecuredLinkedList;
use sn_messaging::{
node::{Network, NodeState, Peer, Proposal, RoutingMsg, Section, Variant},
section_info::Error as TargetSectionError,
DestInfo, EndUser, Itinerary, SectionAuthorityProvider, SrcLocation,
DestInfo, EndUser, Itinerary, MessageId, SectionAuthorityProvider, SrcLocation,
};
use std::net::SocketAddr;
use tokio::sync::mpsc;
Expand Down Expand Up @@ -294,7 +294,13 @@ impl Core {
pub fn set_joins_allowed(&self, joins_allowed: bool) -> Result<Vec<Command>> {
let mut commands = Vec::new();
if self.is_elder() && joins_allowed != self.joins_allowed {
commands.extend(self.propose(Proposal::JoinsAllowed(joins_allowed))?);
let active_members: Vec<XorName> = self
.section
.active_members()
.map(|peer| *peer.name())
.collect();
let msg_id = MessageId::from_content(&active_members)?;
commands.extend(self.propose(Proposal::JoinsAllowed((msg_id, joins_allowed)))?);
}
Ok(commands)
}
Expand Down
2 changes: 1 addition & 1 deletion src/routing/core/messaging/handling/agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Core {
)?])
}
Proposal::JoinsAllowed(joins_allowed) => {
self.joins_allowed = joins_allowed;
self.joins_allowed = joins_allowed.1;
Ok(vec![])
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/routing/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{
messages::RoutingMsgUtils,
network::NetworkUtils,
node::Node,
peer::PeerUtils,
relocation::RelocateState,
section::{SectionAuthorityProviderUtils, SectionKeyShare, SectionKeysProvider, SectionUtils},
};
Expand Down Expand Up @@ -168,7 +169,15 @@ impl Core {
commands.extend(self.promote_and_demote_elders()?);
// Whenever there is an elders change, casting a round of joins_allowed
// proposals to sync.
commands.extend(self.propose(Proposal::JoinsAllowed(self.joins_allowed))?);
let active_members: Vec<XorName> = self
.section
.active_members()
.map(|peer| *peer.name())
.collect();
let msg_id = MessageId::from_content(&active_members)?;
commands.extend(
self.propose(Proposal::JoinsAllowed((msg_id, self.joins_allowed)))?,
);
}

self.print_network_stats();
Expand Down

0 comments on commit abc2531

Please sign in to comment.