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

Commit

Permalink
fix: avoid over relocation
Browse files Browse the repository at this point in the history
To avoid over relocation, we only allow relocation when there is
enough elder nodes. AND, the newly joined node will not be relocated
immediately.
  • Loading branch information
maqi authored and dirvine committed Dec 25, 2020
1 parent d17809f commit 989529c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/routing/approved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{
EldersInfo, MemberInfo, PeerState, Section, SectionKeyShare, SectionKeysProvider,
SectionProofChain, MIN_AGE,
},
RECOMMENDED_SECTION_SIZE,
ELDER_SIZE, RECOMMENDED_SECTION_SIZE,
};
use bls_dkg::key_gen::message::Message as DkgMessage;
use bytes::Bytes;
Expand Down Expand Up @@ -1191,19 +1191,29 @@ impl Approved {
) -> Result<Vec<Command>> {
let mut commands = vec![];

// Do not carry out relocation when there is not enough elder nodes.
if self.section.elders_info().elders.len() < ELDER_SIZE {
return Ok(commands);
}

let relocations =
relocation::actions(&self.section, &self.network, churn_name, churn_signature);

for (info, action) in relocations {
let peer = info.peer;

// The newly joined node is not being relocated immediately.
if peer.name() == churn_name {
continue;
}

debug!(
"Relocating {:?} to {} (on churn of {})",
info.peer,
peer,
action.destination(),
churn_name
);

let peer = info.peer;

commands.extend(self.vote(Vote::Offline(info.relocate(*action.destination())))?);

match action {
Expand Down

0 comments on commit 989529c

Please sign in to comment.