arnaucube
arnaucube/go-dvotePublic Self-hosted repository
Fix getRoot

Signed-off-by: p4u <p4u@dabax.net>
p4u p4u@dabax.net
Mon, 11 Feb 2019 20:03:49 +0100
commit

b8dccadfaaad6d3c50489a4ecfc5f7d3e2b7a17f

parent

6d3bf7c18d3dcf2929bcb98dce88e16593e6f68c

1 files changed, 7 insertions(+), 3 deletions(-)

jump to
M tree/tree.go → tree/tree.go

@@ -101,7 +101,7 @@ e.Entry().HIndex(), e.Entry().HValue()), nil

} func (t *Tree) GetRoot() string { - return t.Tree.RootKey().String() + return common3.HexEncode(t.Tree.RootKey().Bytes()) } func (t *Tree) GetIndex(data []byte) (string, error) {

@@ -126,9 +126,13 @@ }

func (t *Tree) Snapshot(root string) (*Tree, error) { var rootHash merkletree.Hash - copy(rootHash[:32], root) - mt, err := t.Tree.Snapshot(&rootHash) snapshotTree := new(Tree) + rootBytes, err := common3.HexDecode(root) + if err != nil { + return snapshotTree, err + } + copy(rootHash[:32], rootBytes) + mt, err := t.Tree.Snapshot(&rootHash) snapshotTree.Tree = mt return snapshotTree, err }