Trait frame_support::migrations::SteppedMigration
source · pub trait SteppedMigration {
type Cursor: FullCodec + MaxEncodedLen;
type Identifier: FullCodec + MaxEncodedLen;
// Required methods
fn id() -> Self::Identifier;
fn step(
cursor: Option<Self::Cursor>,
meter: &mut WeightMeter,
) -> Result<Option<Self::Cursor>, SteppedMigrationError>;
// Provided methods
fn max_steps() -> Option<u32> { ... }
fn transactional_step(
cursor: Option<Self::Cursor>,
meter: &mut WeightMeter,
) -> Result<Option<Self::Cursor>, SteppedMigrationError> { ... }
}
Expand description
A migration that can proceed in multiple steps.
Required Associated Types§
sourcetype Cursor: FullCodec + MaxEncodedLen
type Cursor: FullCodec + MaxEncodedLen
The cursor type that stores the progress (aka. state) of this migration.
sourcetype Identifier: FullCodec + MaxEncodedLen
type Identifier: FullCodec + MaxEncodedLen
The unique identifier type of this migration.
Required Methods§
sourcefn id() -> Self::Identifier
fn id() -> Self::Identifier
The unique identifier of this migration.
If two migrations have the same identifier, then they are assumed to be identical.
sourcefn step(
cursor: Option<Self::Cursor>,
meter: &mut WeightMeter,
) -> Result<Option<Self::Cursor>, SteppedMigrationError>
fn step( cursor: Option<Self::Cursor>, meter: &mut WeightMeter, ) -> Result<Option<Self::Cursor>, SteppedMigrationError>
Try to migrate as much as possible with the given weight.
ANY STORAGE CHANGES MUST BE ROLLED-BACK BY THE CALLER UPON ERROR. This is necessary
since the caller cannot return a cursor in the error case. Self::transactional_step
is
provided as convenience for a caller. A cursor of None
implies that the migration is at
its end. A migration that once returned Nonce
is guaranteed to never be called again.
Provided Methods§
sourcefn max_steps() -> Option<u32>
fn max_steps() -> Option<u32>
The maximum number of steps that this migration can take.
This can be used to enforce progress and prevent migrations becoming stuck forever. A
migration that exceeds its max steps is treated as failed. None
means that there is no
limit.
sourcefn transactional_step(
cursor: Option<Self::Cursor>,
meter: &mut WeightMeter,
) -> Result<Option<Self::Cursor>, SteppedMigrationError>
fn transactional_step( cursor: Option<Self::Cursor>, meter: &mut WeightMeter, ) -> Result<Option<Self::Cursor>, SteppedMigrationError>
Same as Self::step
, but rolls back pending changes in the error case.