Skip to content
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

Merged
merged 5 commits into from
Sep 16, 2024
Merged

add kvstore #1004

merged 5 commits into from
Sep 16, 2024

Conversation

Eslam-Nawara
Copy link
Contributor

Description

  • add kvsotre to the chain go client
  • add tests

Related Issues:

@Eslam-Nawara Eslam-Nawara force-pushed the development-add-kvstore-to-go-client branch from 03daef8 to bb04c00 Compare September 12, 2024 11:21
@Eslam-Nawara Eslam-Nawara force-pushed the development-add-kvstore-to-go-client branch from b00a6af to 4b29d39 Compare September 16, 2024 12:22
@Eslam-Nawara Eslam-Nawara marked this pull request as ready for review September 16, 2024 12:42
@@ -1,16 +1,16 @@
module github.com/threefoldtech/tfchain/clients/tfchain-client-go

go 1.17
go 1.21
Copy link
Member

@sameh-farouk sameh-farouk Sep 16, 2024

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.

Comment on lines 138 to 157
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
}
Copy link
Member

@sameh-farouk sameh-farouk Sep 16, 2024

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 ?

@Eslam-Nawara Eslam-Nawara force-pushed the development-add-kvstore-to-go-client branch from 5cfd565 to 1ccac55 Compare September 16, 2024 14:56
@sameh-farouk sameh-farouk merged commit 10a6bc1 into development Sep 16, 2024
2 of 3 checks passed
@sameh-farouk sameh-farouk deleted the development-add-kvstore-to-go-client branch September 16, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add KV store module in GO client
2 participants