Skip to content

Commit

Permalink
Merge pull request #370 from qianbin/strong-txpool
Browse files Browse the repository at this point in the history
Strong txpool
  • Loading branch information
libotony authored Jul 23, 2020
2 parents 65e4078 + cce07e6 commit b3a2aec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion txpool/tx_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (o *txObject) Executable(chain *chain.Chain, state *state.State, headBlock
return false, errors.New("gas too large")
case o.IsExpired(headBlock.Number()):
return false, errors.New("expired")
case o.BlockRef().Number() > headBlock.Number()+uint32(3600*24/thor.BlockInterval):
case o.BlockRef().Number() > headBlock.Number()+uint32(5*60/thor.BlockInterval):
// reject deferred tx which will be applied after 5mins
return false, errors.New("block ref out of schedule")
}

Expand Down
2 changes: 1 addition & 1 deletion txpool/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (p *TxPool) wash(headBlock *block.Header) (executables tx.Transactions, rem
}

// out of lifetime
if now > txObj.timeAdded+int64(p.options.MaxLifetime) {
if !txObj.localSubmitted && now > txObj.timeAdded+int64(p.options.MaxLifetime) {
toRemove = append(toRemove, txObj)
log.Debug("tx washed out", "id", txObj.ID(), "err", "out of lifetime")
continue
Expand Down
3 changes: 2 additions & 1 deletion txpool/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ func TestAdd(t *testing.T) {
tx *Tx.Transaction
errStr string
}{
{newTx(pool.repo.ChainTag(), nil, 21000, tx.NewBlockRef(200), 100, nil, Tx.Features(0), acc), "tx rejected: tx is not executable"},
{newTx(pool.repo.ChainTag(), nil, 21000, tx.NewBlockRef(10), 100, nil, Tx.Features(0), acc), "tx rejected: tx is not executable"},
{newTx(pool.repo.ChainTag(), nil, 21000, tx.NewBlockRef(100), 100, nil, Tx.Features(0), acc), "tx rejected: block ref out of schedule"},
{newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, &thor.Bytes32{1}, Tx.Features(0), acc), "tx rejected: tx is not executable"},
{newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, &thor.Bytes32{1}, Tx.Features(2), acc), "tx rejected: unsupported features"},
{badReserved, "tx rejected: unsupported features"},
Expand Down

0 comments on commit b3a2aec

Please sign in to comment.