collections: fix typos in README (#20452)

This commit is contained in:
PolyMa 2024-05-25 17:15:02 +08:00 committed by GitHub
parent e05fe92593
commit 5930ee345b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -193,7 +193,7 @@ We already know the first three arguments of the ``NewMap`` function.
The fourth parameter is our `KeyCodec`, we know that the ``Map`` has `string` as key so we pass it a `KeyCodec` that handles strings as keys.
The fifth parameter is our `ValueCodec`, we know that the `Map` as a `uint64` as value so we pass it a `ValueCodec` that handles uint64.
The fifth parameter is our `ValueCodec`, we know that the `Map` has a `uint64` as value so we pass it a `ValueCodec` that handles uint64.
Collections already comes with all the required implementations for golang primitive types.
@ -587,7 +587,7 @@ Let's analyse each method in the example and how it makes use of the `Iterate` a
In `GetAllAccounts` we pass to our `Iterate` a nil `Ranger`. This means that the returned `Iterator` will include
all the existing keys within the collection.
Then we use some the `Values` method from the returned `Iterator` API to collect all the values into a slice.
Then we use the `Values` method from the returned `Iterator` API to collect all the values into a slice.
`Iterator` offers other methods such as `Keys()` to collect only the keys and not the values and `KeyValues` to collect
all the keys and values.
@ -602,7 +602,7 @@ we instruct it to report us results in reverse order through `Descending`
Then we pass the range instruction to `Iterate` and get an `Iterator`, which will contain only the results
we specified in the range.
Then we use again th `Values` method of the `Iterator` to collect all the results.
Then we use again the `Values` method of the `Iterator` to collect all the results.
`collections.Range` also offers a `Prefix` API which is not applicable to all keys types,
for example uint64 cannot be prefix because it is of constant size, but a `string` key
@ -777,7 +777,7 @@ We use the `collections.Join` function to generate the composite key.
`collections.Pair` contains the two keys we have joined, it also exposes two methods: `K1` to fetch the 1st part of the
key and `K2` to fetch the second part.
As always, we use the `collections.Map.Set` method to map the composite key to our value (`math.Int`in this case)
As always, we use the `collections.Map.Set` method to map the composite key to our value (`math.Int` in this case)
#### GetBalance
@ -860,7 +860,7 @@ Then we can see in our `AccountIndexes` struct the `Number` field is defined as:
```
Where the first type parameter is `uint64`, which is the field type of our index.
The second type parameter is the primary key `sdk.AccAddress`
The second type parameter is the primary key `sdk.AccAddress`.
And the third type parameter is the actual object we're storing `authtypes.BaseAccount`.
Then we create a `NewAccountIndexes` function that instantiates and returns the `AccountsIndexes` struct.