Update Tree interface to match last censustree version

This commit is contained in:
arnaucube
2021-08-10 19:10:44 +02:00
parent 3e47da54b6
commit 195cbad761
3 changed files with 350 additions and 34 deletions

14
asmt.go
View File

@@ -9,6 +9,7 @@ import (
"go.vocdoni.io/dvote/censustree"
"go.vocdoni.io/dvote/log"
"go.vocdoni.io/proto/build/go/models"
"git.sr.ht/~sircmpwn/go-bare"
"github.com/p4u/asmt/db"
@@ -31,6 +32,9 @@ type Tree struct {
snapshotSize uint64
}
// check that censustree.Tree interface is matched by Tree
var _ censustree.Tree = (*Tree)(nil)
type Proof struct {
Bitmap []byte
Length int
@@ -114,6 +118,16 @@ func (t *Tree) IsPublic() bool {
return atomic.LoadUint32(&t.public) == 1
}
// Type returns the numeric identifier for the censusTree implementation
func (t *Tree) Type() models.Census_Type {
return models.Census_UNKNOWN
}
// TypeString returns the name identifying the censustree implementation
func (t *Tree) TypeString() string {
return models.Census_Type_name[int32(t.Type())] // reuse the naming generated by protobuf
}
// Commit saves permanently the tree on disk
func (t *Tree) Commit() error {
if t.snapshotRoot != nil {

7
go.mod
View File

@@ -3,11 +3,12 @@ module github.com/p4u/asmt
go 1.16
require (
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210227202403-5dae5c48f917
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9
github.com/aergoio/aergo-lib v1.0.2
github.com/guptarohit/asciigraph v0.4.1
github.com/stretchr/testify v1.7.0
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca
go.vocdoni.io/dvote v0.6.1-0.20210326182730-ba86106de602
golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670
go.vocdoni.io/dvote v1.0.4-0.20210809075252-5e1716d5e0f5
go.vocdoni.io/proto v1.0.4-0.20210726091234-bceaf416353b
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
)

363
go.sum

File diff suppressed because it is too large Load Diff