core, light: address comments

This commit is contained in:
rjl493456442 2019-08-09 22:34:47 +08:00
parent acad1475e6
commit 80bb52c244
2 changed files with 6 additions and 18 deletions

View file

@ -217,8 +217,7 @@ type TxPool struct {
signer types.Signer signer types.Signer
mu sync.RWMutex mu sync.RWMutex
homestead bool // Fork indicator whether we are in the homestead stage. istanbul bool // Fork indicator whether we are in the istanbul stage.
istanbul bool // Fork indicator whether we are in the istanbul stage.
currentState *state.StateDB // Current state in the blockchain head currentState *state.StateDB // Current state in the blockchain head
pendingNonces *txNoncer // Pending state tracking virtual nonces pendingNonces *txNoncer // Pending state tracking virtual nonces
@ -543,7 +542,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
return ErrInsufficientFunds return ErrInsufficientFunds
} }
// Ensure the transaction has more gas than the basic tx fee. // Ensure the transaction has more gas than the basic tx fee.
intrGas, err := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead, pool.istanbul) intrGas, err := IntrinsicGas(tx.Data(), tx.To() == nil, true, pool.istanbul)
if err != nil { if err != nil {
return err return err
} }
@ -1122,14 +1121,9 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
senderCacher.recover(pool.signer, reinject) senderCacher.recover(pool.signer, reinject)
pool.addTxsLocked(reinject, false) pool.addTxsLocked(reinject, false)
// Update all fork indicators by next pending block number. // Update all fork indicator by next pending block number.
next := new(big.Int).Add(newHead.Number, big.NewInt(1)) next := new(big.Int).Add(newHead.Number, big.NewInt(1))
pool.istanbul = pool.chainconfig.IsIstanbul(next) pool.istanbul = pool.chainconfig.IsIstanbul(next)
if pool.istanbul {
pool.homestead = true
} else {
pool.homestead = pool.chainconfig.IsHomestead(next)
}
} }
// promoteExecutables moves transactions that have become processable from the // promoteExecutables moves transactions that have become processable from the

View file

@ -68,8 +68,7 @@ type TxPool struct {
mined map[common.Hash][]*types.Transaction // mined transactions by block hash mined map[common.Hash][]*types.Transaction // mined transactions by block hash
clearIdx uint64 // earliest block nr that can contain mined tx info clearIdx uint64 // earliest block nr that can contain mined tx info
homestead bool // Fork indicator whether we are in the homestead stage. istanbul bool // Fork indicator whether we are in the istanbul stage.
istanbul bool // Fork indicator whether we are in the istanbul stage.
} }
// TxRelayBackend provides an interface to the mechanism that forwards transacions // TxRelayBackend provides an interface to the mechanism that forwards transacions
@ -312,14 +311,9 @@ func (pool *TxPool) setNewHead(head *types.Header) {
m, r := txc.getLists() m, r := txc.getLists()
pool.relay.NewHead(pool.head, m, r) pool.relay.NewHead(pool.head, m, r)
// Update fork indicators by next pending block number // Update fork indicator by next pending block number
next := new(big.Int).Add(head.Number, big.NewInt(1)) next := new(big.Int).Add(head.Number, big.NewInt(1))
pool.istanbul = pool.config.IsIstanbul(next) pool.istanbul = pool.config.IsIstanbul(next)
if pool.istanbul {
pool.homestead = true
} else {
pool.homestead = pool.config.IsHomestead(next)
}
} }
// Stop stops the light transaction pool // Stop stops the light transaction pool
@ -387,7 +381,7 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error
} }
// Should supply enough intrinsic gas // Should supply enough intrinsic gas
gas, err := core.IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead, pool.istanbul) gas, err := core.IntrinsicGas(tx.Data(), tx.To() == nil, true, pool.istanbul)
if err != nil { if err != nil {
return err return err
} }