-
Notifications
You must be signed in to change notification settings - Fork 11
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
add kvstore #1004
add kvstore #1004
Conversation
03daef8
to
bb04c00
Compare
b00a6af
to
4b29d39
Compare
@@ -1,16 +1,16 @@ | |||
module github.com/threefoldtech/tfchain/clients/tfchain-client-go | |||
|
|||
go 1.17 | |||
go 1.21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason to update the MSV?
Given that there haven't been any significant changes, I assume we don't need this.
clients/tfchain-client-go/kvstore.go
Outdated
func decodeSecondKey(storageKey types.StorageKey, identity Identity) (key []byte, err error) { | ||
// remove 16 bytes(32 in hex) pallet and map prefixes. | ||
// pallet prefix (8 bytes): twox64(pallet_name) | ||
// map prefix (8bytes) twox64(map_name) | ||
prefixLen := 32 | ||
|
||
// the storage key contains two keys (AccountID and Vec<u8>) | ||
// remove the length of the first key(AccountID) | ||
// the hasher `Blake2_128Concat` includes a 16-byte hash followed by the AccountID | ||
firstKeyLen := 32 + len(identity.PublicKey()) | ||
|
||
offset := prefixLen + firstKeyLen | ||
|
||
if len(storageKey) < offset { | ||
return nil, errors.New(fmt.Sprintf("failed to decode second key, storage key len should not be less than %d bytes", offset)) | ||
} | ||
|
||
err = Decode(storageKey[offset:], &key) | ||
return key, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this function to utils.go ?
5cfd565
to
1ccac55
Compare
Description
Related Issues: