This repository was archived by the owner on Aug 19, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -137,16 +137,23 @@ Notice that the last item (the `double_map`) specifies the "hasher" (the hash al
137
137
one of its key. Keep reading for [ more information about the different hashing algorithms] ( #Hashing-Algorithms ) and when
138
138
to use them.
139
139
140
- ### Custom Getter Method Names
140
+ ### Getter Methods
141
141
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.
143
149
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:
145
152
146
153
``` rust
147
154
decl_storage! {
148
155
trait Store for Module <T : Trait > as Example {
149
- pub SomeValue get (some_value ): u64 ;
156
+ pub SomeValue get (fn some_value ): u64 ;
150
157
}
151
158
}
152
159
```
You can’t perform that action at this time.
0 commit comments