OSDN Git Service

Mov late node sync test (#529)
[bytom/vapor.git] / application / mov / mov_core.go
index 76154dc..4a08cf5 100644 (file)
@@ -53,10 +53,15 @@ func NewCoreWithDB(store *database.LevelDBMovStore, startBlockHeight uint64) *Co
 // ApplyBlock parse pending order and cancel from the the transactions of block
 // and add pending order to the dex db, remove cancel order from dex db.
 func (m *Core) ApplyBlock(block *types.Block) error {
-       if block.Height <= m.startBlockHeight {
+       if block.Height < m.startBlockHeight {
                return nil
        }
 
+       if block.Height == m.startBlockHeight {
+               blockHash := block.Hash()
+               return m.InitChainStatus(&blockHash)
+       }
+
        if err := m.validateMatchedTxSequence(block.Transactions); err != nil {
                return err
        }
@@ -113,6 +118,11 @@ func (m *Core) DetachBlock(block *types.Block) error {
                return nil
        }
 
+       if block.Height == m.startBlockHeight {
+               m.movStore.Clear()
+               return nil
+       }
+
        deleteOrders, addOrders, err := decodeTxsOrders(block.Transactions)
        if err != nil {
                return err