Merge pull request #2126 from nspcc-dev/prevent-inconsistent-exit-2.x
core: take an addblock lock on exit
This commit is contained in:
commit
f38d62ab14
1 changed files with 1 additions and 0 deletions
|
@ -300,6 +300,7 @@ func (bc *Blockchain) Run() {
|
|||
persistTimer := time.NewTimer(persistInterval)
|
||||
defer func() {
|
||||
persistTimer.Stop()
|
||||
bc.addLock.Lock() // Prevent changing state, but do not release the lock, we're about to exit.
|
||||
if err := bc.persist(); err != nil {
|
||||
bc.log.Warn("failed to persist", zap.Error(err))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue