From 6f88d04ac48b2181b0ca8b42d2429c1a67663941 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 6 Dec 2016 02:52:07 -0800 Subject: [PATCH] call db.SetSync when necessary --- blockchain/store.go | 5 ++++- state/state.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/blockchain/store.go b/blockchain/store.go index 3b4226429..06b3c4275 100644 --- a/blockchain/store.go +++ b/blockchain/store.go @@ -172,6 +172,9 @@ func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, s // Done! bs.height = height + + // Flush + bs.db.SetSync(nil, nil) } func (bs *BlockStore) saveBlockPart(height int, index int, part *types.Part) { @@ -213,7 +216,7 @@ func (bsj BlockStoreStateJSON) Save(db dbm.DB) { if err != nil { PanicSanity(Fmt("Could not marshal state bytes: %v", err)) } - db.Set(blockStoreKey, bytes) + db.SetSync(blockStoreKey, bytes) } func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON { diff --git a/state/state.go b/state/state.go index f8b5dfc2a..af2f69cae 100644 --- a/state/state.go +++ b/state/state.go @@ -80,7 +80,7 @@ func (s *State) Copy() *State { func (s *State) Save() { s.mtx.Lock() defer s.mtx.Unlock() - s.db.Set(stateKey, s.Bytes()) + s.db.SetSync(stateKey, s.Bytes()) } func (s *State) Equals(s2 *State) bool {