core: add Persist() to dao()

Hide its internals a little, which is gonna be useful for future composition.
This commit is contained in:
Roman Khimov 2019-12-12 21:17:13 +03:00
parent eb1749d190
commit 09223236f9
2 changed files with 9 additions and 3 deletions

View file

@ -505,7 +505,7 @@ func (bc *Blockchain) storeBlock(block *Block) error {
v.LoadScript(t.Script) v.LoadScript(t.Script)
err := v.Run() err := v.Run()
if !v.HasFailed() { if !v.HasFailed() {
_, err := systemInterop.dao.store.Persist() _, err := systemInterop.dao.Persist()
if err != nil { if err != nil {
return errors.Wrap(err, "failed to persist invocation results") 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 { if err != nil {
return err return err
} }
@ -690,7 +690,7 @@ func (bc *Blockchain) persist() error {
err error err error
) )
persisted, err = bc.dao.store.Persist() persisted, err = bc.dao.Persist()
if err != nil { if err != nil {
return err return err
} }

View file

@ -555,3 +555,9 @@ func (dao *dao) IsDoubleSpend(tx *transaction.Transaction) bool {
} }
return false return false
} }
// Persist flushes all the changes made into the (supposedly) persistent
// underlying store.
func (dao *dao) Persist() (int, error) {
return dao.store.Persist()
}