Type Definition dock_runtime::accumulator::Accumulators

source ·
pub type Accumulators<T> = StorageMap<_GeneratedPrefixForStorageAccumulators<T>, Blake2_128Concat, AccumulatorId, AccumulatorWithUpdateInfo<T>, OptionQuery, GetDefault, GetDefault>;
Expand description

Stores latest accumulator as key value: accumulator id -> (created_at, last_updated_at, Accumulator) created_at is the block number when the accumulator was created and is intended to serve as a starting point for anyone looking for all updates to the accumulator. last_updated_at is the block number when the last update was sent. created_at and last_updated_at together indicate which blocks should be considered for finding accumulator updates. Historical values and updates are persisted as events indexed with the accumulator id. The reason for not storing past values is to save storage in chain state. Another option could have been to store block numbers for the updates so that each block from created_at doesn’t need to be scanned but even that requires large storage as we expect millions of updates. Just keeping the latest accumulated value allows for any potential on chain verification as well.