pub trait GetStorageVersion {
    type CurrentStorageVersion;

    // Required methods
    fn current_storage_version() -> Self::CurrentStorageVersion;
    fn on_chain_storage_version() -> StorageVersion;
}
Expand description

Provides information about the storage version of a pallet.

It differentiates between current and on-chain storage version. Both should be only out of sync when a new runtime upgrade was applied and the runtime migrations did not yet executed. Otherwise it means that the pallet works with an unsupported storage version and unforeseen stuff can happen.

The current storage version is the version of the pallet as supported at runtime. The active storage version is the version of the pallet in the storage.

It is required to update the on-chain storage version manually when a migration was applied.

Required Associated Types§

source

type CurrentStorageVersion

This will be filled out by the pallet macro.

If the storage_version attribute isn’t given this is set to NoStorageVersionSet to inform the user that the attribute is missing. This should prevent that the user forgets to set a storage version when required. However, this will only work when the user actually tries to call Self::current_storage_version to compare it against the Self::on_chain_storage_version. If the attribute is given, this will be set to StorageVersion.

Required Methods§

source

fn current_storage_version() -> Self::CurrentStorageVersion

Returns the current storage version as supported by the pallet.

source

fn on_chain_storage_version() -> StorageVersion

Returns the on-chain storage version of the pallet as stored in the storage.

Implementors§