rebroadcast unseen messages
This commit is contained in:
parent
7d97ba5ee0
commit
1326c6cf5a
@ -132,8 +132,7 @@ impl Tendermint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn broadcast_message(&self, block_hash: Option<BlockHash>) {
|
fn broadcast_message(&self, message: Bytes) {
|
||||||
if let Some(message) = self.generate_message(block_hash) {
|
|
||||||
if let Some(ref channel) = *self.message_channel.lock() {
|
if let Some(ref channel) = *self.message_channel.lock() {
|
||||||
match channel.send(ClientIoMessage::BroadcastMessage(message)) {
|
match channel.send(ClientIoMessage::BroadcastMessage(message)) {
|
||||||
Ok(_) => trace!(target: "poa", "timeout: BroadcastMessage message sent."),
|
Ok(_) => trace!(target: "poa", "timeout: BroadcastMessage message sent."),
|
||||||
@ -141,7 +140,6 @@ impl Tendermint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_message(&self, block_hash: Option<BlockHash>) -> Option<Bytes> {
|
fn generate_message(&self, block_hash: Option<BlockHash>) -> Option<Bytes> {
|
||||||
if let Some(ref ap) = *self.account_provider.lock() {
|
if let Some(ref ap) = *self.account_provider.lock() {
|
||||||
@ -158,6 +156,12 @@ impl Tendermint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generate_and_broadcast_message(&self, block_hash: Option<BlockHash>) {
|
||||||
|
if let Some(message) = self.generate_message(block_hash) {
|
||||||
|
self.broadcast_message(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn to_step(&self, step: Step) {
|
fn to_step(&self, step: Step) {
|
||||||
*self.step.write() = step;
|
*self.step.write() = step;
|
||||||
match step {
|
match step {
|
||||||
@ -173,7 +177,7 @@ impl Tendermint {
|
|||||||
Some(ref m) => m.block_hash,
|
Some(ref m) => m.block_hash,
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
self.broadcast_message(block_hash)
|
self.generate_and_broadcast_message(block_hash)
|
||||||
},
|
},
|
||||||
Step::Precommit => {
|
Step::Precommit => {
|
||||||
trace!(target: "poa", "to_step: Transitioning to Precommit.");
|
trace!(target: "poa", "to_step: Transitioning to Precommit.");
|
||||||
@ -184,7 +188,7 @@ impl Tendermint {
|
|||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
self.broadcast_message(block_hash);
|
self.generate_and_broadcast_message(block_hash);
|
||||||
},
|
},
|
||||||
Step::Commit => {
|
Step::Commit => {
|
||||||
trace!(target: "poa", "to_step: Transitioning to Commit.");
|
trace!(target: "poa", "to_step: Transitioning to Commit.");
|
||||||
@ -352,6 +356,7 @@ impl Engine for Tendermint {
|
|||||||
// Check if the message is known.
|
// Check if the message is known.
|
||||||
if self.votes.vote(message.clone(), sender).is_none() {
|
if self.votes.vote(message.clone(), sender).is_none() {
|
||||||
trace!(target: "poa", "handle_message: Processing new authorized message: {:?}", &message);
|
trace!(target: "poa", "handle_message: Processing new authorized message: {:?}", &message);
|
||||||
|
self.broadcast_message(rlp.as_raw().to_vec());
|
||||||
let is_newer_than_lock = match *self.lock_change.read() {
|
let is_newer_than_lock = match *self.lock_change.read() {
|
||||||
Some(ref lock) => &message > lock,
|
Some(ref lock) => &message > lock,
|
||||||
None => true,
|
None => true,
|
||||||
@ -704,7 +709,7 @@ mod tests {
|
|||||||
vote(&engine, |mh| tap.sign(v1, None, mh).ok().map(H520::from), h, r, Step::Precommit, proposal);
|
vote(&engine, |mh| tap.sign(v1, None, mh).ok().map(H520::from), h, r, Step::Precommit, proposal);
|
||||||
vote(&engine, |mh| tap.sign(v0, None, mh).ok().map(H520::from), h, r, Step::Precommit, proposal);
|
vote(&engine, |mh| tap.sign(v0, None, mh).ok().map(H520::from), h, r, Step::Precommit, proposal);
|
||||||
|
|
||||||
::std::thread::sleep(::std::time::Duration::from_millis(40));
|
::std::thread::sleep(::std::time::Duration::from_millis(5));
|
||||||
assert_eq!(*test_io.received.lock(), Some(ClientIoMessage::SubmitSeal(proposal.unwrap(), seal)));
|
assert_eq!(*test_io.received.lock(), Some(ClientIoMessage::SubmitSeal(proposal.unwrap(), seal)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user