Add Last db view in kvdb and statedb

Last db view is an opened pebble db which always contains a checkpoint from the
last batch.  Methods to access this last batch are thread safe so that views of
the last checkpoint can be made anywhere and with a consistent view of the
state.
This commit is contained in:
Eduard S
2021-02-02 15:42:52 +01:00
parent ca7fa8ae2e
commit 6590c47a9a
12 changed files with 422 additions and 160 deletions

View File

@@ -176,7 +176,7 @@ func TestZKInputsEmpty(t *testing.T) {
assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
// check that there are no accounts
accs, err := sdb.GetAccounts()
accs, err := sdb.TestGetAccounts()
require.NoError(t, err)
assert.Equal(t, 0, len(accs))
@@ -208,7 +208,7 @@ func TestZKInputsEmpty(t *testing.T) {
rootNonZero := sdb.MT.Root()
// check that there is 1 account
accs, err = sdb.GetAccounts()
accs, err = sdb.TestGetAccounts()
require.NoError(t, err)
assert.Equal(t, 1, len(accs))
@@ -234,7 +234,7 @@ func TestZKInputsEmpty(t *testing.T) {
assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
// check that there is still 1 account
accs, err = sdb.GetAccounts()
accs, err = sdb.TestGetAccounts()
require.NoError(t, err)
assert.Equal(t, 1, len(accs))