-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Substrate Storage Deep Dive Workshop/Tutorial #19
Comments
I'd be happy to help with it but probably not as the main owner of the task. An important idea worth noting: Another one that I've learned the hard way: |
@kianenigma can you share a code sample to get an idea of what you mean? |
In cases where you have a very large vec, and you access indexes individually (no need to iterate all of them etc.), you can chunck the Vec into Sets (of 64 element per se) and fetch one set from mem. Indexing would simply be:
inserting and removing needs a bit bookkeeping though; one thing for sure is that you probably want a new storage item all the time that points to the next free set. Both |
And continue the conversation about off-chain storage, as we've already done here: |
AFAIK, storing enums is not documented anywhere. TIL // Can't derive Default like you can for structs.
#[derive(Encode, Decode, Clone, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Status {
Active,
Sold,
SellerReviewed,
BuyerReviewed,
}
// Without a manual implementation, you can't use the enum as a storage value
impl Default for Status {
fn default() -> Self {
Self::Active
}
} |
You can store it without a default. Either you specify the default yourself in the decl storage line or you store it as an optional. |
There are a lot of tricks and nuances to using storage in Substrate.
Supported storage types (found here)
Implications of using different storage types for efficiency
Using
Vec
, implications of letting users input the value for thisStorage API: get, put, insert, take, append, etc...
Storing Structs (advance things)
Storage Upgrades or Migrations, how and when it is possible
Charging fees for users storing items
Genesis configuration, default value, "add extra genesis"
decl_storage macro in general
using the Polkadot UI for a number of different storage scenarios
more?
@thiolliere may be able to help us here with the details of some of these things if he is so kind :)
The text was updated successfully, but these errors were encountered: