Skip to content

Commit

Permalink
Add round_is_done flag to Master status
Browse files Browse the repository at this point in the history
After this flag is changed to true, ignore other messages until starting next round.
  • Loading branch information
rantan committed Jan 15, 2020
1 parent f9a93ce commit 03e47dc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/signer_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub enum NodeState {
block_shared_keys: Option<(bool, FE, GE)>,
candidate_block: Block,
signatures: BTreeMap<SignerID, (FE, FE)>,
round_is_done: bool,
},
Member {
block_key: Option<FE>,
Expand Down Expand Up @@ -301,6 +302,7 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
shared_block_secrets: BTreeMap::new(),
candidate_block: block,
signatures: BTreeMap::new(),
round_is_done: false,
}
}

Expand Down Expand Up @@ -375,6 +377,7 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
block_shared_keys,
shared_block_secrets,
signatures,
round_is_done: false,
..
} => {
let key = self.create_block_vss(block.clone());
Expand All @@ -384,6 +387,7 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
shared_block_secrets: shared_block_secrets.clone(),
candidate_block: block.clone(),
signatures: signatures.clone(),
round_is_done: false,
}
}
_ => self.current_state.clone(),
Expand Down Expand Up @@ -565,6 +569,7 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
shared_block_secrets,
candidate_block,
signatures,
round_is_done: false,
..
} => {
let mut new_shared_block_secrets = shared_block_secrets.clone();
Expand All @@ -590,13 +595,15 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
block_shared_keys: Some((keys.0, keys.1.x_i, keys.1.y)),
candidate_block: candidate_block.clone(),
signatures: signatures.clone(),
round_is_done: false,
},
None => NodeState::Master {
block_key: block_key.clone(),
shared_block_secrets: new_shared_block_secrets,
block_shared_keys: None,
candidate_block: candidate_block.clone(),
signatures: signatures.clone(),
round_is_done: false,
},
}
}
Expand Down Expand Up @@ -655,6 +662,7 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
shared_block_secrets,
candidate_block,
signatures,
round_is_done: false,
} => {
let mut new_signatures = signatures.clone();
new_signatures.insert(from, (gamma_i, e));
Expand Down Expand Up @@ -753,6 +761,15 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
receiver_id: None,
};
self.connection_manager.broadcast_message(message);

return NodeState::Master {
block_key: block_key.clone(),
block_shared_keys: block_shared_keys.clone(),
shared_block_secrets: shared_block_secrets.clone(),
candidate_block: candidate_block.clone(),
signatures: new_signatures,
round_is_done: true,
};
}
Err(e) => {
log::error!("block rejected by Tapyrus Core: {:?}", e);
Expand All @@ -765,6 +782,7 @@ impl<T: TapyrusApi, C: ConnectionManager> SignerNode<T, C> {
shared_block_secrets: shared_block_secrets.clone(),
candidate_block: candidate_block.clone(),
signatures: new_signatures,
round_is_done: false,
}
}
state @ _ => state.clone(),
Expand Down

0 comments on commit 03e47dc

Please sign in to comment.