Skip to content

Commit

Permalink
removed "urgent" flag from start_hbbft_epoch, because start_hbbft_epo…
Browse files Browse the repository at this point in the history
…ch is never urgent.
  • Loading branch information
SurfingNerd committed Mar 18, 2023
1 parent cb330dc commit 2b65638
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions crates/ethcore/src/engines/hbbft/hbbft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::{
cmp::{max, min},
collections::BTreeMap,
convert::TryFrom,
ops::{BitXor, DerefMut},
ops::{BitXor},
sync::{atomic::AtomicBool, Arc, Mutex, Weak},
time::Duration,
};
Expand Down Expand Up @@ -206,7 +206,7 @@ impl IoHandler<()> for TransitionHandler {

// If the maximum block time has been reached we trigger a new block in any case.
if self.max_block_time_remaining(c.clone()) == Duration::from_secs(0) {
self.engine.start_hbbft_epoch(c, false);
self.engine.start_hbbft_epoch(c);
}

// Transactions may have been submitted during creation of the last block, trigger the
Expand Down Expand Up @@ -727,22 +727,20 @@ impl HoneyBadgerBFT {
Ok(())
}

fn start_hbbft_epoch(&self, client: Arc<dyn EngineClient>, urgent: bool) {
fn start_hbbft_epoch(&self, client: Arc<dyn EngineClient>) {
if self.is_syncing(&client) {
return;
}

let mut lock =
if urgent {self.hbbft_state.write() } else {
if let Some(try_lock) = self.hbbft_state.try_write_for(std::time::Duration::from_millis(10)) {
try_lock
} else {
let step =
match self.hbbft_state.try_write_for(std::time::Duration::from_millis(10)) {
Some(mut state_lock) => {
state_lock.try_send_contribution(client.clone(), &self.signer)
},
None => {
return;
}
},
};

let step = lock.try_send_contribution(client.clone(), &self.signer);
std::mem::drop(lock);

if let Some((step, network_info)) = step {
self.process_step(client, step, &network_info)
Expand Down Expand Up @@ -784,7 +782,7 @@ impl HoneyBadgerBFT {

// If current time larger than phase start time, start a new block.
if genesis_transition_time.as_u64() < unix_now_secs() {
self.start_hbbft_epoch(client, false);
self.start_hbbft_epoch(client);
}
}
}
Expand Down Expand Up @@ -1177,7 +1175,7 @@ impl HoneyBadgerBFT {
fn start_hbbft_epoch_if_ready(&self) {
if let Some(client) = self.client_arc() {
if self.transaction_queue_and_time_thresholds_reached(&client) {
self.start_hbbft_epoch(client, false);
self.start_hbbft_epoch(client);
}
}
}
Expand Down

0 comments on commit 2b65638

Please sign in to comment.