From 03e47dc6b738479ca46d7ee7302f7cdba82e2a71 Mon Sep 17 00:00:00 2001 From: Kohei Taniguchi Date: Wed, 15 Jan 2020 11:29:51 +0900 Subject: [PATCH] Add round_is_done flag to Master status After this flag is changed to true, ignore other messages until starting next round. --- src/signer_node.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/signer_node.rs b/src/signer_node.rs index 3f7cf1eed..55cbdf2ec 100644 --- a/src/signer_node.rs +++ b/src/signer_node.rs @@ -107,6 +107,7 @@ pub enum NodeState { block_shared_keys: Option<(bool, FE, GE)>, candidate_block: Block, signatures: BTreeMap, + round_is_done: bool, }, Member { block_key: Option, @@ -301,6 +302,7 @@ impl SignerNode { shared_block_secrets: BTreeMap::new(), candidate_block: block, signatures: BTreeMap::new(), + round_is_done: false, } } @@ -375,6 +377,7 @@ impl SignerNode { block_shared_keys, shared_block_secrets, signatures, + round_is_done: false, .. } => { let key = self.create_block_vss(block.clone()); @@ -384,6 +387,7 @@ impl SignerNode { shared_block_secrets: shared_block_secrets.clone(), candidate_block: block.clone(), signatures: signatures.clone(), + round_is_done: false, } } _ => self.current_state.clone(), @@ -565,6 +569,7 @@ impl SignerNode { shared_block_secrets, candidate_block, signatures, + round_is_done: false, .. } => { let mut new_shared_block_secrets = shared_block_secrets.clone(); @@ -590,6 +595,7 @@ impl SignerNode { 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(), @@ -597,6 +603,7 @@ impl SignerNode { block_shared_keys: None, candidate_block: candidate_block.clone(), signatures: signatures.clone(), + round_is_done: false, }, } } @@ -655,6 +662,7 @@ impl SignerNode { shared_block_secrets, candidate_block, signatures, + round_is_done: false, } => { let mut new_signatures = signatures.clone(); new_signatures.insert(from, (gamma_i, e)); @@ -753,6 +761,15 @@ impl SignerNode { 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); @@ -765,6 +782,7 @@ impl SignerNode { shared_block_secrets: shared_block_secrets.clone(), candidate_block: candidate_block.clone(), signatures: new_signatures, + round_is_done: false, } } state @ _ => state.clone(),