diff options
Diffstat (limited to 'core/tx_pool.go')
-rw-r--r-- | core/tx_pool.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/core/tx_pool.go b/core/tx_pool.go index f1e5f0bdd..edcbc21eb 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -92,6 +92,7 @@ type TxPool struct { eventMux *event.TypeMux events event.Subscription localTx *txSet + signer types.Signer mu sync.RWMutex pending map[common.Address]*txList // All currently processable transactions @@ -108,6 +109,7 @@ type TxPool struct { func NewTxPool(config *params.ChainConfig, eventMux *event.TypeMux, currentStateFn stateFn, gasLimitFn func() *big.Int) *TxPool { pool := &TxPool{ config: config, + signer: types.NewEIP155Signer(config.ChainId), pending: make(map[common.Address]*txList), queue: make(map[common.Address]*txList), all: make(map[common.Hash]*types.Transaction), @@ -139,8 +141,10 @@ func (pool *TxPool) eventLoop() { switch ev := ev.Data.(type) { case ChainHeadEvent: pool.mu.Lock() - if ev.Block != nil && pool.config.IsHomestead(ev.Block.Number()) { - pool.homestead = true + if ev.Block != nil { + if pool.config.IsHomestead(ev.Block.Number()) { + pool.homestead = true + } } pool.resetState() @@ -272,7 +276,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error { return err } - from, err := tx.From() + from, err := types.Sender(pool.signer, tx) if err != nil { return ErrInvalidSender } @@ -307,7 +311,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error { return ErrInsufficientFunds } - intrGas := IntrinsicGas(tx.Data(), MessageCreatesContract(tx), pool.homestead) + intrGas := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead) if tx.Gas().Cmp(intrGas) < 0 { return ErrIntrinsicGas } @@ -336,7 +340,7 @@ func (pool *TxPool) add(tx *types.Transaction) error { if to := tx.To(); to != nil { rcpt = common.Bytes2Hex(to[:4]) } - from, _ := tx.From() // from already verified during tx validation + from, _ := types.Sender(pool.signer, tx) // from already verified during tx validation glog.Infof("(t) 0x%x => %s (%v) %x\n", from[:4], rcpt, tx.Value, hash) } return nil @@ -347,7 +351,7 @@ func (pool *TxPool) add(tx *types.Transaction) error { // Note, this method assumes the pool lock is held! func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction) { // Try to insert the transaction into the future queue - from, _ := tx.From() // already validated + from, _ := types.Sender(pool.signer, tx) // already validated if pool.queue[from] == nil { pool.queue[from] = newTxList(false) } @@ -459,7 +463,7 @@ func (pool *TxPool) removeTx(hash common.Hash) { if !ok { return } - addr, _ := tx.From() // already validated during insertion + addr, _ := types.Sender(pool.signer, tx) // already validated during insertion // Remove it from the list of known transactions delete(pool.all, hash) |