diff --git a/api/censusdb/censusdb.go b/api/censusdb/censusdb.go index f4aaa31ec..639a39985 100644 --- a/api/censusdb/censusdb.go +++ b/api/censusdb/censusdb.go @@ -109,9 +109,6 @@ func (c *CensusDB) New(censusID []byte, censusType models.Census_Type, return nil, err } ref.tree = tree - if uri != "" { - ref.tree.Publish() - } return ref, nil } @@ -150,9 +147,6 @@ func (c *CensusDB) Load(censusID []byte, authToken *uuid.UUID) (*CensusRef, erro if err != nil { return nil, err } - if ref.URI != "" { - ref.tree.Publish() - } root, err := ref.Tree().Root() if err != nil { return nil, err diff --git a/api/censuses.go b/api/censuses.go index bd51e95a9..1ce032b35 100644 --- a/api/censuses.go +++ b/api/censuses.go @@ -710,7 +710,6 @@ func (a *API) censusPublishHandler(msg *apirest.APIdata, ctx *httprouter.HTTPCon if err := newRef.Tree().ImportDump(dump); err != nil { return err } - newRef.Tree().Publish() var data []byte if data, err = json.Marshal(&Census{ diff --git a/censustree/censustree.go b/censustree/censustree.go index 5bb3be4a3..75d35970d 100644 --- a/censustree/censustree.go +++ b/censustree/censustree.go @@ -6,7 +6,6 @@ import ( "fmt" "math/big" "sync" - "sync/atomic" "go.vocdoni.io/dvote/db" "go.vocdoni.io/dvote/db/prefixeddb" @@ -24,7 +23,6 @@ var censusWeightKey = []byte("censusWeight") // updates it. type Tree struct { tree *tree.Tree - public atomic.Bool censusType models.Census_Type hashFunc func(...[]byte) ([]byte, error) hashLen int @@ -146,16 +144,6 @@ func (t *Tree) FromRoot(root []byte) (*Tree, error) { return &Tree{tree: treeFromRoot, censusType: t.Type()}, nil } -// Publish makes a merkle tree available for queries. Application layer should -// call Publish() before considering the Tree available. -func (t *Tree) Publish() { t.public.Store(true) } - -// Unpublish makes a merkle tree not available for queries. -func (t *Tree) Unpublish() { t.public.Store(false) } - -// IsPublic returns true if the tree is available. -func (t *Tree) IsPublic() bool { return t.public.Load() } - // Root wraps tree.Tree.Root. func (t *Tree) Root() ([]byte, error) { return t.tree.Root(nil) diff --git a/censustree/censustree_test.go b/censustree/censustree_test.go index ad776d6a2..f25f6a239 100644 --- a/censustree/censustree_test.go +++ b/censustree/censustree_test.go @@ -16,28 +16,6 @@ import ( // The proper tests are in tree package, here there are tests that check the // added code in the CensusTree wrapper. -func TestPublish(t *testing.T) { - db := metadb.NewTest(t) - censusTree, err := New(Options{Name: "test", ParentDB: db, MaxLevels: DefaultMaxLevels, - CensusType: models.Census_ARBO_BLAKE2B}) - qt.Assert(t, err, qt.IsNil) - rnd := testutil.NewRandom(0) - key, value := rnd.RandomBytes(DefaultMaxKeyLen), rnd.RandomBytes(32) - qt.Assert(t, censusTree.Add(key, value), qt.IsNil) - - qt.Assert(t, censusTree.IsPublic(), qt.IsFalse) - - censusTree.Publish() - qt.Assert(t, censusTree.IsPublic(), qt.IsTrue) - - recValue, _, err := censusTree.GenProof(key) - qt.Assert(t, err, qt.IsNil) - qt.Assert(t, value, qt.DeepEquals, recValue) - - censusTree.Unpublish() - qt.Assert(t, censusTree.IsPublic(), qt.IsFalse) -} - func TestImportWeighted(t *testing.T) { db := metadb.NewTest(t) censusTree, err := New(Options{Name: "test", ParentDB: db, MaxLevels: DefaultMaxLevels, @@ -118,8 +96,6 @@ func TestWeightedProof(t *testing.T) { err = censusTree.Add(userKey, userWeight) qt.Assert(t, err, qt.IsNil) - censusTree.Publish() - // generate and test the proof value, siblings, err := censusTree.GenProof(userKey) qt.Assert(t, err, qt.IsNil) diff --git a/test/testcommon/testvoteproof/voteproof.go b/test/testcommon/testvoteproof/voteproof.go index 4850472fb..c8cee499d 100644 --- a/test/testcommon/testvoteproof/voteproof.go +++ b/test/testcommon/testvoteproof/voteproof.go @@ -67,7 +67,6 @@ func CreateKeysAndBuildCensus(t *testing.T, size int) ([]*ethereum.SignKeys, []b hashedKeys = append(hashedKeys, c) } - tr.Publish() var proofs [][]byte for i := range keys { _, proof, err := tr.GenProof(hashedKeys[i]) diff --git a/vochain/vote_test.go b/vochain/vote_test.go index 64549ca67..4a0cee0d1 100644 --- a/vochain/vote_test.go +++ b/vochain/vote_test.go @@ -37,8 +37,6 @@ func testCreateKeysAndBuildWeightedZkCensus(t *testing.T, size int, weight *big. qt.Check(t, err, qt.IsNil) } - tr.Publish() - root, err := tr.Root() qt.Check(t, err, qt.IsNil) var proofs [][]byte @@ -74,7 +72,6 @@ func testCreateKeysAndBuildCensus(t *testing.T, size int) ([]*ethereum.SignKeys, hashedKeys = append(hashedKeys, c) } - tr.Publish() var proofs [][]byte for i := range keys { _, proof, err := tr.GenProof(hashedKeys[i])