From 8fe5d2e785d82500a9b0ab6f481ff7adfb32a173 Mon Sep 17 00:00:00 2001 From: shenao78 Date: Wed, 1 Apr 2020 19:59:17 +0800 Subject: [PATCH] prevent duplicate init chain status --- application/mov/mov_core.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/mov/mov_core.go b/application/mov/mov_core.go index 80d7875e..f91f742c 100644 --- a/application/mov/mov_core.go +++ b/application/mov/mov_core.go @@ -17,6 +17,7 @@ import ( ) var ( + errChainStatusHasAlreadyInit = errors.New("mov chain status has already initialized") errInvalidTradePairs = errors.New("The trade pairs in the tx input is invalid") errStatusFailMustFalse = errors.New("status fail of transaction does not allow to be true") errInputProgramMustP2WMCScript = errors.New("input program of trade tx must p2wmc script") @@ -127,6 +128,10 @@ func (m *Core) DetachBlock(block *types.Block) error { // InitChainStatus used to init the start block height and start block hash to store func (m *Core) InitChainStatus(startHash *bc.Hash) error { + if _, err := m.movStore.GetMovDatabaseState(); err == nil { + return errChainStatusHasAlreadyInit + } + return m.movStore.InitDBState(m.startBlockHeight, startHash) } -- 2.11.0