-
Notifications
You must be signed in to change notification settings - Fork 129
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
feat(rpc): Implement childstate_getStorageHash
RPC call
#1805
Changes from 12 commits
ad38cc2
7b634a1
88316c7
10e41bf
b3ad509
99b8f30
08e9dc6
e658579
c39f2b3
1f36b77
d18dc61
cd4f579
d16c306
1740d97
12f7675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,13 @@ type GetKeysRequest struct { | |
Hash common.Hash | ||
} | ||
|
||
// GetStorageHash the request to get the entry child storage hash | ||
type GetStorageHash struct { | ||
KeyChild []byte | ||
EntryKey []byte | ||
Hash common.Hash | ||
} | ||
|
||
// ChildStateModule is the module responsible to implement all the childstate RPC calls | ||
type ChildStateModule struct { | ||
storageAPI StorageAPI | ||
|
@@ -68,3 +75,26 @@ func (cs *ChildStateModule) GetKeys(_ *http.Request, req *GetKeysRequest, res *[ | |
*res = hexKeys | ||
return nil | ||
} | ||
|
||
// GetStorageHash returns the hash of a child storage entry | ||
func (cs *ChildStateModule) GetStorageHash(_ *http.Request, req *GetStorageHash, res *string) error { | ||
if req.Hash == common.EmptyHash { | ||
req.Hash = cs.blockAPI.BestBlockHash() | ||
} | ||
|
||
stateRoot, err := cs.storageAPI.GetStateRootFromBlock(&req.Hash) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
item, err := cs.storageAPI.GetStorageFromChild(stateRoot, req.KeyChild, req.EntryKey) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(item) > 0 { | ||
*res = common.BytesToHash(item).String() | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the return value should also be an optional, but this will return the same value for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
since block hash is optional, can you make this
*common.Hash
?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.
Done!