Skip to main content
added 277 characters in body
Source Link
Angelo
  • 501
  • 3
  • 10

Say I have a StorageDoubleMap that stores Data structs for each user and ContextId

    #[pallet::storage]
    pub type Info<T: Config> = StorageDoubleMap<
        _,
        Blake2_128Concat,
        T::AccountId,
        Twox64Concat,
        T::ContextId,
        Data,
    >;

Is there an option to limit the amount of entries per AccountId? Or should I keep a count of entries in a separate map?

Update:

Accessing a specific ContextId for an AccountId quickly is important to me, that's why I chose StorageDoubleMap.

Moreover, a common operation will be to iterate over all ContextIds for an AccountId, which StorageDoubleMap also has support for.

Say I have a StorageDoubleMap that stores Data structs for each user and ContextId

    #[pallet::storage]
    pub type Info<T: Config> = StorageDoubleMap<
        _,
        Blake2_128Concat,
        T::AccountId,
        Twox64Concat,
        T::ContextId,
        Data,
    >;

Is there an option to limit the amount of entries per AccountId? Or should I keep a count of entries in a separate map?

Say I have a StorageDoubleMap that stores Data structs for each user and ContextId

    #[pallet::storage]
    pub type Info<T: Config> = StorageDoubleMap<
        _,
        Blake2_128Concat,
        T::AccountId,
        Twox64Concat,
        T::ContextId,
        Data,
    >;

Is there an option to limit the amount of entries per AccountId? Or should I keep a count of entries in a separate map?

Update:

Accessing a specific ContextId for an AccountId quickly is important to me, that's why I chose StorageDoubleMap.

Moreover, a common operation will be to iterate over all ContextIds for an AccountId, which StorageDoubleMap also has support for.

Source Link
Angelo
  • 501
  • 3
  • 10

How to limit the number of values by prefix in StorageDoubleMap?

Say I have a StorageDoubleMap that stores Data structs for each user and ContextId

    #[pallet::storage]
    pub type Info<T: Config> = StorageDoubleMap<
        _,
        Blake2_128Concat,
        T::AccountId,
        Twox64Concat,
        T::ContextId,
        Data,
    >;

Is there an option to limit the amount of entries per AccountId? Or should I keep a count of entries in a separate map?