From fbe88ee27571dfd582dbe494e5709e5795fb9205 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 17 Oct 2017 12:13:37 +0200 Subject: [PATCH] Clean up state.State as we only support persistence --- state/merkle.go | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/state/merkle.go b/state/merkle.go index ec81c6d00..2373d27d3 100644 --- a/state/merkle.go +++ b/state/merkle.go @@ -5,19 +5,17 @@ import "github.com/tendermint/iavl" // State represents the app states, separating the commited state (for queries) // from the working state (for CheckTx and AppendTx) type State struct { - committed *Bonsai - deliverTx SimpleDB - checkTx SimpleDB - persistent bool + committed *Bonsai + deliverTx SimpleDB + checkTx SimpleDB } func NewState(tree *iavl.VersionedTree) *State { base := NewBonsai(tree) return &State{ - committed: base, - deliverTx: base.Checkpoint(), - checkTx: base.Checkpoint(), - persistent: true, + committed: base, + deliverTx: base.Checkpoint(), + checkTx: base.Checkpoint(), } } @@ -45,14 +43,6 @@ func (s State) LatestHash() []byte { return s.committed.Tree.Hash() } -// BatchSet is used for some weird magic in storing the new height -func (s *State) BatchSet(key, value []byte) { - if s.persistent { - // This is in the batch with the Save, but not in the tree - s.committed.Tree.BatchSet(key, value) - } -} - // Commit save persistent nodes to the database and re-copies the trees func (s *State) Commit(version uint64) ([]byte, error) { // commit (if we didn't do hash earlier) @@ -62,15 +52,11 @@ func (s *State) Commit(version uint64) ([]byte, error) { } var hash []byte - if s.persistent { - if s.committed.Tree.Size() > 0 || s.committed.Tree.LatestVersion() > 0 { - hash, err = s.committed.Tree.SaveVersion(version) - if err != nil { - return nil, err - } + if s.committed.Tree.Size() > 0 || s.committed.Tree.LatestVersion() > 0 { + hash, err = s.committed.Tree.SaveVersion(version) + if err != nil { + return nil, err } - } else { - hash = s.committed.Tree.Hash() } s.deliverTx = s.committed.Checkpoint()