Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Refactor StorageInstance trait to be usable more easily #7659

Merged
4 commits merged into from
Dec 3, 2020

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Dec 2, 2020

StorageInstance is introduced to be used alongside storage types. It was meant to be implemented by macro, thus I tried to make it as straightforward as possible to implement from the macro (just some associated type and constant). But this is a rather ugly trait and it is less usable then.

Thus this PR refactors it to make it more usable and idiomatic.

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Dec 2, 2020
@gui1117 gui1117 added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Dec 2, 2020
@@ -1733,11 +1733,10 @@ pub trait Instance: 'static {

/// An instance of a storage.
///
/// It is required the the couple `(PalletInfo::name<Pallet>(), STORAGE_PREFIX)` is unique.
/// It is required the the couple `(pallet_prefix(), STORAGE_PREFIX)` is unique.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we use this tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use it as a tuple, but just all storages must use different pallet_prefix and storage_prefix otherwise they would be after the same key twox_128(pallet_prefix)++twox_128(storage_prefix).

But the doc is not good, I updated

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
@gui1117
Copy link
Contributor Author

gui1117 commented Dec 3, 2020

bot merge

@ghost
Copy link

ghost commented Dec 3, 2020

Waiting for commit status.

@ghost ghost merged commit 9f57f27 into master Dec 3, 2020
@ghost ghost deleted the gui-refactor-storage-instance branch December 3, 2020 10:51
darkfriend77 pushed a commit to mogwaicoin/substrate that referenced this pull request Jan 11, 2021
…#7659)

* refactor StorageInstance to be usable without macros

* better description

* update types  doc

* Update frame/support/src/traits.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants