Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Commit 5301a8a

Browse files
committed
Clarify the get extension to decl_storage
1 parent 8bdb445 commit 5301a8a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

current/runtime/storage.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,23 @@ Notice that the last item (the `double_map`) specifies the "hasher" (the hash al
137137
one of its key. Keep reading for [more information about the different hashing algorithms](#Hashing-Algorithms) and when
138138
to use them.
139139

140-
### Custom Getter Method Names
140+
### Getter Methods
141141

142-
The `decl_storage` macro makes it easy to provide a custom name for a Storage Item's `get()` method.
142+
The `decl_storage` macro provides an optional `get` extension that can be used to implement a getter method for a storage
143+
item on the module that contains that storage item; the extension takes the desired name of the getter function as an
144+
argument. If you omit this optional extension, you will still be able to access the storage item's value, but you will
145+
not be able to do so by way of a getter method implemented on the module; instead, you will need to need to use
146+
[the storage item's `get` method](#Methods). Keep in mind that the optional `get` extension only impacts the way that
147+
the storage item can be accessed from within Substrate code; you will always be able to
148+
[query the storage of your runtime](#Querying-Storage) to get the value of a storage item.
143149

144-
Here is an example of renaming the `get()` function of a Storage Value named `SomeValue` to `some_value()`:
150+
Here is an example that implements a getter method named `some_value` for a Storage Value named `SomeValue`. This module
151+
would now have access to a `Self::some_value()` method in addition to the `SomeValue::get()` method:
145152

146153
```rust
147154
decl_storage! {
148155
trait Store for Module<T: Trait> as Example {
149-
pub SomeValue get(some_value): u64;
156+
pub SomeValue get(fn some_value): u64;
150157
}
151158
}
152159
```

0 commit comments

Comments
 (0)