Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add block_delta parameter to start_beefy_gadget (#151)
Browse files Browse the repository at this point in the history
* Add block_delta parameter

* rename to min_block_delta
  • Loading branch information
adoerr authored Apr 16, 2021
1 parent 9da8233 commit 40e81a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub async fn start_beefy_gadget<B, P, BE, C, N, SO>(
network: N,
signed_commitment_sender: notification::BeefySignedCommitmentSender<B, P::Signature>,
_sync_oracle: SO,
min_block_delta: u32,
prometheus_registry: Option<Registry>,
) where
B: Block,
Expand Down Expand Up @@ -129,6 +130,7 @@ pub async fn start_beefy_gadget<B, P, BE, C, N, SO>(
signed_commitment_sender,
gossip_engine,
gossip_validator,
min_block_delta,
metrics,
);

Expand Down
7 changes: 4 additions & 3 deletions client/beefy/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ where
signed_commitment_sender: notification::BeefySignedCommitmentSender<B, P::Signature>,
gossip_engine: Arc<Mutex<GossipEngine<B>>>,
gossip_validator: Arc<BeefyGossipValidator<B, P>>,
min_block_delta: u32,
metrics: Option<Metrics>,
rounds: round::Rounds<MmrRootHash, NumberFor<B>, P::Public, P::Signature>,
finality_notifications: FinalityNotifications<B>,
min_interval: u32,
/// Best block we received a GRANDPA notification for
best_grandpa_block: NumberFor<B>,
/// Best block a BEEFY voting round has been concluded for
Expand Down Expand Up @@ -103,6 +103,7 @@ where
signed_commitment_sender: notification::BeefySignedCommitmentSender<B, P::Signature>,
gossip_engine: GossipEngine<B>,
gossip_validator: Arc<BeefyGossipValidator<B, P>>,
min_block_delta: u32,
metrics: Option<Metrics>,
) -> Self {
BeefyWorker {
Expand All @@ -111,10 +112,10 @@ where
signed_commitment_sender,
gossip_engine: Arc::new(Mutex::new(gossip_engine)),
gossip_validator,
min_block_delta,
metrics,
rounds: round::Rounds::new(ValidatorSet::empty()),
finality_notifications: client.finality_notification_stream(),
min_interval: 2,
best_grandpa_block: client.info().finalized_number,
best_beefy_block: None,
best_block_voted_on: Zero::zero(),
Expand Down Expand Up @@ -148,7 +149,7 @@ where
let diff = self.best_grandpa_block.saturating_sub(best_beefy_block);
let diff = diff.saturated_into::<u32>();
let next_power_of_two = (diff / 2).next_power_of_two();
let next_block_to_vote_on = self.best_block_voted_on + self.min_interval.max(next_power_of_two).into();
let next_block_to_vote_on = self.best_block_voted_on + self.min_block_delta.max(next_power_of_two).into();

trace!(
target: "beefy",
Expand Down

0 comments on commit 40e81a6

Please sign in to comment.