From e602bf1c9f6ea6acc6e5d93ddb5bbc27d025e2d1 Mon Sep 17 00:00:00 2001 From: Cong Zhao Date: Wed, 17 Apr 2019 16:50:45 +0800 Subject: [PATCH 1/2] expose nodedb as we don't like interact with iavl tree during snapshot --- mutable_tree.go | 4 ---- nodedb.go | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mutable_tree.go b/mutable_tree.go index 50dd688..9a2fecb 100644 --- a/mutable_tree.go +++ b/mutable_tree.go @@ -501,7 +501,3 @@ func (tree *MutableTree) addOrphans(orphans []*Node) { tree.orphans[string(node.hash)] = node.version } } - -func (tree *MutableTree) GetVersions() map[int64]bool { - return tree.versions -} diff --git a/nodedb.go b/nodedb.go index 0aafb43..7770714 100644 --- a/nodedb.go +++ b/nodedb.go @@ -16,6 +16,10 @@ const ( hashSize = tmhash.Size ) +// expose nodeDB so that state sync can directly save serialized node into +// db without restore it as iavl tree first +type NodeDB = nodeDB + var ( // All node keys are prefixed with the byte 'n'. This ensures no collision is // possible with the other keys, and makes them easier to traverse. They are indexed by the node hash. From ad09593d46827f1e2445a27613f9dcadae49ee6b Mon Sep 17 00:00:00 2001 From: yutianwu Date: Tue, 18 Jun 2019 17:36:30 +0800 Subject: [PATCH 2/2] [R4R] Add set version in mutable tree (#8) * add set version * set latest version --- mutable_tree.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mutable_tree.go b/mutable_tree.go index 9a2fecb..526cd61 100644 --- a/mutable_tree.go +++ b/mutable_tree.go @@ -224,6 +224,12 @@ func (tree *MutableTree) Load() (int64, error) { return tree.LoadVersion(int64(0)) } +// SetVersion set current version of the tree. Only used in upgrade +func (tree *MutableTree) SetVersion(version int64) { + tree.version = version + tree.ndb.latestVersion = version +} + // Returns the version number of the latest version found func (tree *MutableTree) LoadVersion(targetVersion int64) (int64, error) { roots, err := tree.ndb.getRoots()