From 09223236f91f1f46433188c8be7f0c59594beb14 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 12 Dec 2019 21:17:13 +0300 Subject: [PATCH] core: add Persist() to dao() Hide its internals a little, which is gonna be useful for future composition. --- pkg/core/blockchain.go | 6 +++--- pkg/core/dao.go | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 3ce0b486e..e92016dc6 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -505,7 +505,7 @@ func (bc *Blockchain) storeBlock(block *Block) error { v.LoadScript(t.Script) err := v.Run() if !v.HasFailed() { - _, err := systemInterop.dao.store.Persist() + _, err := systemInterop.dao.Persist() if err != nil { return errors.Wrap(err, "failed to persist invocation results") } @@ -554,7 +554,7 @@ func (bc *Blockchain) storeBlock(block *Block) error { } } } - _, err := cache.store.Persist() + _, err := cache.Persist() if err != nil { return err } @@ -690,7 +690,7 @@ func (bc *Blockchain) persist() error { err error ) - persisted, err = bc.dao.store.Persist() + persisted, err = bc.dao.Persist() if err != nil { return err } diff --git a/pkg/core/dao.go b/pkg/core/dao.go index c6bbd2ddc..846847b7d 100644 --- a/pkg/core/dao.go +++ b/pkg/core/dao.go @@ -555,3 +555,9 @@ func (dao *dao) IsDoubleSpend(tx *transaction.Transaction) bool { } return false } + +// Persist flushes all the changes made into the (supposedly) persistent +// underlying store. +func (dao *dao) Persist() (int, error) { + return dao.store.Persist() +}