core: refactoring blockchain state and storage

add dao which takes care about all CRUD operations on storage
remove blockchain state since everything is stored on change
remove storage operations from structs(entities)
move structs to entities package
This commit is contained in:
Vsevolod Brekelov 2019-11-25 20:39:11 +03:00
parent c43ff15c78
commit ec17654986
39 changed files with 958 additions and 1258 deletions

View file

@ -56,7 +56,7 @@ func TestAddBlock(t *testing.T) {
for _, block := range blocks {
key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesLE())
if _, err := bc.store.Get(key); err != nil {
if _, err := bc.dao.store.Get(key); err != nil {
t.Fatalf("block %s not persisted", block.Hash())
}
}
@ -170,7 +170,7 @@ func TestClose(t *testing.T) {
// It's a hack, but we use internal knowledge of MemoryStore
// implementation which makes it completely unusable (up to panicing)
// after Close().
_ = bc.store.Put([]byte{0}, []byte{1})
_ = bc.dao.store.Put([]byte{0}, []byte{1})
// This should never be executed.
assert.Nil(t, t)