// 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
}
return nil
}
+ if block.Height == m.startBlockHeight {
+ m.movStore.Clear()
+ return nil
+ }
+
deleteOrders, addOrders, err := decodeTxsOrders(block.Transactions)
if err != nil {
return err