mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Ensure election offchain workers don't overlap (#8828)
* Initial version, well tested, should work fine. * Add one last log line * Update frame/election-provider-multi-phase/src/unsigned.rs Co-authored-by: Gavin Wood <gavin@parity.io> * Update frame/election-provider-multi-phase/src/unsigned.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/election-provider-multi-phase/src/unsigned.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fix a few more things * fix build * rewrite the whole thing with a proper lock * clean * clean some nits * Add unit tests. * Update primitives/runtime/src/offchain/storage_lock.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix test * Fix tests Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -66,6 +66,7 @@ use crate::traits::AtLeast32BitUnsigned;
|
||||
use codec::{Codec, Decode, Encode};
|
||||
use sp_core::offchain::{Duration, Timestamp};
|
||||
use sp_io::offchain;
|
||||
use sp_std::fmt;
|
||||
|
||||
/// Default expiry duration for time based locks in milliseconds.
|
||||
const STORAGE_LOCK_DEFAULT_EXPIRY_DURATION: Duration = Duration::from_millis(20_000);
|
||||
@@ -173,6 +174,17 @@ impl<B: BlockNumberProvider> Default for BlockAndTimeDeadline<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockNumberProvider> fmt::Debug for BlockAndTimeDeadline<B>
|
||||
where <B as BlockNumberProvider>::BlockNumber: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("BlockAndTimeDeadline")
|
||||
.field("block_number", &self.block_number)
|
||||
.field("timestamp", &self.timestamp)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Lockable based on block number and timestamp.
|
||||
///
|
||||
/// Expiration is defined if both, block number _and_ timestamp
|
||||
|
||||
Reference in New Issue
Block a user