Slots: Ensure that a race betwen finalized and best number is taken care off (#10876)

This commit is contained in:
Bastian Köcher
2022-02-17 17:05:18 +01:00
committed by GitHub
parent f5af00fe1b
commit c498215866
+3 -1
View File
@@ -789,7 +789,9 @@ where
return false
}
let unfinalized_block_length = chain_head_number - finalized_number;
// There can be race between getting the finalized number and getting the best number.
// So, better be safe than sorry.
let unfinalized_block_length = chain_head_number.saturating_sub(finalized_number);
let interval =
unfinalized_block_length.saturating_sub(self.unfinalized_slack) / self.authoring_bias;
let interval = interval.min(self.max_interval);