Timestamp¶
Calls¶
set¶
Set the current time.
This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time.
The timestamp should be greater than the previous one by the amount specified by
[Config::MinimumPeriod
].
The dispatch origin for this call must be None.
This dispatch class is Mandatory to ensure it gets executed in the block. Be aware that changing the complexity of this call could result exhausting the resources in a block to execute any other calls.
## Complexity
- O(1)
(Note that implementations of OnTimestampSet
must also be O(1)
)
- 1 storage read and 1 storage mutation (codec O(1)
because of DidUpdate::take
in
on_finalize
)
- 1 event handler on_timestamp_set
. Must be O(1)
.
Attributes¶
Name | Type |
---|---|
now | T::Moment |
Python¶
call = substrate.compose_call(
'Timestamp', 'set', {'now': 'u64'}
)
Storage functions¶
DidUpdate¶
Whether the timestamp has been updated in this block.
This value is updated to true
upon successful submission of a timestamp by a node.
It is then checked at the end of each block execution in the on_finalize
hook.
Python¶
result = substrate.query(
'Timestamp', 'DidUpdate', []
)
Return value¶
'bool'
Now¶
The current time for the current block.
Python¶
result = substrate.query(
'Timestamp', 'Now', []
)
Return value¶
'u64'
Constants¶
MinimumPeriod¶
The minimum period between blocks.
Be aware that this is different to the expected period that the block production apparatus provides. Your chosen consensus system will generally work with this to determine a sensible block time. For example, in the Aura pallet it will be double this period on default settings.
Value¶
6000
Python¶
constant = substrate.get_constant('Timestamp', 'MinimumPeriod')