|
@ -7,7 +7,6 @@ import ( |
|
|
"sync/atomic" |
|
|
"sync/atomic" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"go.vocdoni.io/dvote/censustree" |
|
|
|
|
|
"go.vocdoni.io/dvote/log" |
|
|
"go.vocdoni.io/dvote/log" |
|
|
"go.vocdoni.io/proto/build/go/models" |
|
|
"go.vocdoni.io/proto/build/go/models" |
|
|
|
|
|
|
|
@ -32,9 +31,6 @@ type Tree struct { |
|
|
snapshotSize uint64 |
|
|
snapshotSize uint64 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// check that censustree.Tree interface is matched by Tree
|
|
|
|
|
|
var _ censustree.Tree = (*Tree)(nil) |
|
|
|
|
|
|
|
|
|
|
|
type Proof struct { |
|
|
type Proof struct { |
|
|
Bitmap []byte |
|
|
Bitmap []byte |
|
|
Length int |
|
|
Length int |
|
@ -57,8 +53,8 @@ const ( |
|
|
dbRootPrefix = "this is the last root for the SMT tree" |
|
|
dbRootPrefix = "this is the last root for the SMT tree" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// NewTree initializes a new AergoSMT tree following the censustree.Tree interface specification.
|
|
|
|
|
|
func NewTree(name, storageDir string) (censustree.Tree, error) { |
|
|
|
|
|
|
|
|
// NewTree initializes a new AergoSMT tree following the Tree interface specification.
|
|
|
|
|
|
func NewTree(name, storageDir string) (*Tree, error) { |
|
|
tr := &Tree{} |
|
|
tr := &Tree{} |
|
|
err := tr.Init(name, storageDir) |
|
|
err := tr.Init(name, storageDir) |
|
|
return tr, err |
|
|
return tr, err |
|
@ -371,7 +367,7 @@ func (t *Tree) ImportDump(data []byte) error { |
|
|
|
|
|
|
|
|
// Snapshot returns a Tree instance of a exiting merkle root.
|
|
|
// Snapshot returns a Tree instance of a exiting merkle root.
|
|
|
// A Snapshot cannot be modified.
|
|
|
// A Snapshot cannot be modified.
|
|
|
func (t *Tree) Snapshot(root []byte) (censustree.Tree, error) { |
|
|
|
|
|
|
|
|
func (t *Tree) Snapshot(root []byte) (*Tree, error) { |
|
|
exist, err := t.HashExists(root) |
|
|
exist, err := t.HashExists(root) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|