• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版35ad7f3f9d390a9712590eefdd7bb24f924d3c93 (tree)
时间2019-10-31 18:28:03
作者shenao78 <shenao.78@163....>
Commitershenao78

Log Message

block height limit for before proposal block

更改概述

差异

--- a/application/mov/mov_core.go
+++ b/application/mov/mov_core.go
@@ -192,6 +192,8 @@ func (m *MovCore) ApplyBlock(block *types.Block) error {
192192 if err := m.movStore.InitDBState(block.Height, &blockHash); err != nil {
193193 return err
194194 }
195+
196+ return nil
195197 }
196198
197199 if err := m.validateMatchedTxSequence(block.Transactions); err != nil {
@@ -299,7 +301,11 @@ func (m *MovCore) DetachBlock(block *types.Block) error {
299301 }
300302
301303 // BeforeProposalBlock return all transactions than can be matched, and the number of transactions cannot exceed the given capacity.
302-func (m *MovCore) BeforeProposalBlock(nodeProgram []byte, gasLeft int64) ([]*types.Tx, int64, error) {
304+func (m *MovCore) BeforeProposalBlock(nodeProgram []byte, blockHeight uint64, gasLeft int64) ([]*types.Tx, int64, error) {
305+ if blockHeight <= m.startBlockHeight {
306+ return nil, 0, nil
307+ }
308+
303309 matchEngine := match.NewEngine(m.movStore, maxFeeRate, nodeProgram)
304310 tradePairMap := make(map[string]bool)
305311 tradePairIterator := database.NewTradePairIterator(m.movStore)
--- a/proposal/proposal.go
+++ b/proposal/proposal.go
@@ -286,7 +286,7 @@ func getTxsFromSubProtocols(chain *protocol.Chain, accountManager *account.Manag
286286 break
287287 }
288288
289- subTxs, gasLeft, err = p.BeforeProposalBlock(cp, gasLeft)
289+ subTxs, gasLeft, err = p.BeforeProposalBlock(cp, chain.BestBlockHeight() + 1, gasLeft)
290290 if err != nil {
291291 log.WithFields(log.Fields{"module": logModule, "index": i, "error": err}).Error("failed on sub protocol txs package")
292292 continue
--- a/protocol/protocol.go
+++ b/protocol/protocol.go
@@ -21,7 +21,7 @@ const (
2121
2222 type Protocoler interface {
2323 Name() string
24- BeforeProposalBlock(nodeProgram []byte, gasLeft int64) ([]*types.Tx, int64, error)
24+ BeforeProposalBlock(nodeProgram []byte, blockHeight uint64, gasLeft int64) ([]*types.Tx, int64, error)
2525 ChainStatus() (uint64, *bc.Hash, error)
2626 ValidateBlock(block *types.Block, verifyResults []*bc.TxVerifyResult) error
2727 ValidateTxs(txs []*types.Tx, verifyResults []*bc.TxVerifyResult) error
Show on old repository browser