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

Split node reference vs. index to separate interfaces for API clarity #91

Merged
merged 8 commits into from
Oct 4, 2024

Conversation

jimthematrix
Copy link
Contributor

The node reference is a hash of the index + value + 1, which is used to refer to a node in the sparse merkle tree. The node index is used to position the node in the tree, which determines the path used to traverse from the root to the leaf node (branch nodes do not have an index).

Currently the usage of a reference and an index are mixed, making it confusing in the code, as well as the API surface. This PR splits them into separate interfaces, with the index being a superset of the reference interface.

Copy link
Contributor

@Chengxuan Chengxuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimthematrix I proposed some suggestions, can you please take a look?

go-sdk/pkg/sparse-merkle-tree/core/node.go Outdated Show resolved Hide resolved
go-sdk/pkg/sparse-merkle-tree/core/node.go Show resolved Hide resolved
go-sdk/pkg/sparse-merkle-tree/core/node.go Outdated Show resolved Hide resolved
go-sdk/pkg/sparse-merkle-tree/core/node.go Outdated Show resolved Hide resolved
go-sdk/pkg/sparse-merkle-tree/core/node.go Outdated Show resolved Hide resolved
go-sdk/pkg/sparse-merkle-tree/core/node.go Outdated Show resolved Hide resolved
go-sdk/pkg/sparse-merkle-tree/core/node.go Outdated Show resolved Hide resolved
jimthematrix and others added 7 commits October 4, 2024 11:16
Co-authored-by: Chengxuan Xing <[email protected]>
Signed-off-by: jimthematrix <[email protected]>
Co-authored-by: Chengxuan Xing <[email protected]>
Signed-off-by: jimthematrix <[email protected]>
Co-authored-by: Chengxuan Xing <[email protected]>
Signed-off-by: jimthematrix <[email protected]>
Co-authored-by: Chengxuan Xing <[email protected]>
Signed-off-by: jimthematrix <[email protected]>
Co-authored-by: Chengxuan Xing <[email protected]>
Signed-off-by: jimthematrix <[email protected]>
Co-authored-by: Chengxuan Xing <[email protected]>
Signed-off-by: jimthematrix <[email protected]>
Signed-off-by: Chengxuan Xing <[email protected]>
@jimthematrix jimthematrix merged commit aa3c1fd into main Oct 4, 2024
6 checks passed
@jimthematrix jimthematrix deleted the index-vs-ref branch October 4, 2024 17:43
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.

2 participants