pub struct RemoveStorage<P: Get<&'static str>, S: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>>(/* private fields */);Expand description
RemoveStorage is a utility struct used to remove a storage item from a specific pallet.
This struct is generic over three parameters:
Pis a type that implements theGettrait for a static string, representing the pallet’s name.Sis a type that implements theGettrait for a static string, representing the storage name.DbWeightis a type that implements theGettrait forRuntimeDbWeight, providing the weight for database operations.
On runtime upgrade, the on_runtime_upgrade function will clear the storage from the specified
storage, logging the number of keys removed. If the try-runtime feature is enabled, the
pre_upgrade and post_upgrade functions can be used to verify the storage removal before and
after the upgrade.
§Examples:
construct_runtime! {
pub enum Runtime
{
System: frame_system = 0,
SomePallet: pallet_something = 1,
YourOtherPallets...
}
};
parameter_types! {
pub const SomePallet: &'static str = "SomePallet";
pub const StorageAccounts: &'static str = "Accounts";
pub const StorageAccountCount: &'static str = "AccountCount";
}
pub type Migrations = (
RemoveStorage<SomePallet, StorageAccounts, RocksDbWeight>,
RemoveStorage<SomePallet, StorageAccountCount, RocksDbWeight>,
AnyOtherMigrations...
);
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
Migrations
>;WARNING: RemoveStorage has no guard rails preventing it from bricking the chain if the
operation of removing storage for the given pallet would exceed the block weight limit.
If your storage has too many keys to be removed in a single block, it is advised to wait for a multi-block scheduler currently under development which will allow for removal of storage items (and performing other heavy migrations) over multiple blocks (see https://github.com/paritytech/substrate/issues/13690).
Trait Implementations§
Source§impl<P: Get<&'static str>, S: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> OnRuntimeUpgrade for RemoveStorage<P, S, DbWeight>
impl<P: Get<&'static str>, S: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> OnRuntimeUpgrade for RemoveStorage<P, S, DbWeight>
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Auto Trait Implementations§
impl<P, S, DbWeight> Freeze for RemoveStorage<P, S, DbWeight>
impl<P, S, DbWeight> RefUnwindSafe for RemoveStorage<P, S, DbWeight>
impl<P, S, DbWeight> Send for RemoveStorage<P, S, DbWeight>
impl<P, S, DbWeight> Sync for RemoveStorage<P, S, DbWeight>
impl<P, S, DbWeight> Unpin for RemoveStorage<P, S, DbWeight>
impl<P, S, DbWeight> UnwindSafe for RemoveStorage<P, S, DbWeight>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.