-
Notifications
You must be signed in to change notification settings - Fork 240
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
Problem: memiavl import API not implemented #941
Conversation
Solution: - implement Import function to convert state-sync snapshot to memiavl snapshot
node := &MemNode{ | ||
height: uint8(n.Height), | ||
size: 1, | ||
version: uint32(n.Version), |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
i := w.nodeIndex | ||
w.nodeIndex++ | ||
return i, nil | ||
return w.writeBranch(node.Version(), uint32(node.Size()), node.Height(), leftIndex+1, node.Hash()) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
right: rightNode, | ||
} | ||
nodeHash := node.Hash() | ||
idx, err := i.writeBranch(node.version, uint32(node.size), node.height, leftIndex+1, nodeHash) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
rightNode := i.nodeStack[len(i.nodeStack)-1] | ||
|
||
node := &MemNode{ | ||
height: uint8(n.Height), |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
node := &MemNode{ | ||
height: uint8(n.Height), | ||
size: leftNode.size + rightNode.size, | ||
version: uint32(n.Version), |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
|
||
if n.Height == 0 { | ||
node := &MemNode{ | ||
height: uint8(n.Height), |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
@mmsqe sorry I did a force push to improve the code reuse, please review again |
if err := buildIndex(input, kvsIndexFile, snapshotDir, int(t.root.Size())); err != nil { | ||
// N = 2L-1 | ||
leaves := (rootIndex + 2) / 2 | ||
if err := buildIndex(input, kvsIndexFile, dir, int(leaves)); err != nil { |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
return errors.New("version overflows uint32") | ||
} | ||
|
||
return writeSnapshot(dir, uint32(version), writeHashIndex, func(w *snapshotWriter) (uint32, error) { |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
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.
np, looks better now
Co-authored-by: mmsqe <tqd0800210105@gmail.com> Signed-off-by: yihuang <huang@crypto.com>
Solution:
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)