Search code examples
substrate

What does this Account storage map definition mean in the pallet_balances?


#[pallet::storage]
    pub type Account<T: Config<I>, I: 'static = ()> = StorageMap<
        _,
        Blake2_128Concat,
        T::AccountId,
        AccountData<T::Balance>,
        ValueQuery,
        GetDefault,
        ConstU32<300_000>,
    >;

What does ConstU32<300_000> mean here? This definition is from the balances pallet.

Also when are we supposed to declare storage maps as pub rather than pub(super)?


Solution

  • What does ConstU32<300_000> mean here?

    This is the maximum number of expected elements in this storage map.

    Also when are we supposed to declare storage maps as pub rather than pub(super)?

    This is just normal rust syntax to tell the compiler who is allowed to access the item. Aka you need to declare it pub when you want to access the item from a different crate.