OSDN Git Service

block height limit for before proposal block mov_merge
authorshenao78 <shenao.78@163.com>
Thu, 31 Oct 2019 09:28:03 +0000 (17:28 +0800)
committershenao78 <shenao.78@163.com>
Thu, 31 Oct 2019 09:28:03 +0000 (17:28 +0800)
application/mov/mov_core.go
proposal/proposal.go
protocol/protocol.go

index a3cbb28..ca29612 100644 (file)
@@ -192,6 +192,8 @@ func (m *MovCore) ApplyBlock(block *types.Block) error {
                if err := m.movStore.InitDBState(block.Height, &blockHash); err != nil {
                        return err
                }
+
+               return nil
        }
 
        if err := m.validateMatchedTxSequence(block.Transactions); err != nil {
@@ -299,7 +301,11 @@ func (m *MovCore) DetachBlock(block *types.Block) error {
 }
 
 // BeforeProposalBlock return all transactions than can be matched, and the number of transactions cannot exceed the given capacity.
-func (m *MovCore) BeforeProposalBlock(nodeProgram []byte, gasLeft int64) ([]*types.Tx, int64, error) {
+func (m *MovCore) BeforeProposalBlock(nodeProgram []byte, blockHeight uint64, gasLeft int64) ([]*types.Tx, int64, error) {
+       if blockHeight <= m.startBlockHeight {
+               return nil, 0, nil
+       }
+
        matchEngine := match.NewEngine(m.movStore, maxFeeRate, nodeProgram)
        tradePairMap := make(map[string]bool)
        tradePairIterator := database.NewTradePairIterator(m.movStore)
index f328269..a31f5bf 100644 (file)
@@ -286,7 +286,7 @@ func getTxsFromSubProtocols(chain *protocol.Chain, accountManager *account.Manag
                        break
                }
 
-               subTxs, gasLeft, err = p.BeforeProposalBlock(cp, gasLeft)
+               subTxs, gasLeft, err = p.BeforeProposalBlock(cp, chain.BestBlockHeight() + 1, gasLeft)
                if err != nil {
                        log.WithFields(log.Fields{"module": logModule, "index": i, "error": err}).Error("failed on sub protocol txs package")
                        continue
index 3dc00fa..fd5a146 100644 (file)
@@ -21,7 +21,7 @@ const (
 
 type Protocoler interface {
        Name() string
-       BeforeProposalBlock(nodeProgram []byte, gasLeft int64) ([]*types.Tx, int64, error)
+       BeforeProposalBlock(nodeProgram []byte, blockHeight uint64, gasLeft int64) ([]*types.Tx, int64, error)
        ChainStatus() (uint64, *bc.Hash, error)
        ValidateBlock(block *types.Block, verifyResults []*bc.TxVerifyResult) error
        ValidateTxs(txs []*types.Tx, verifyResults []*bc.TxVerifyResult) error