aboutsummaryrefslogtreecommitdiffstats
path: root/core/tx_pool.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-11-02 20:44:13 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-11-13 21:55:30 +0800
commit4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188 (patch)
tree5c55a3088c944ddf517aa4d7c85c5dc7f02d00e4 /core/tx_pool.go
parent5cd86443ee071b5e3abe4995c777ce467c29f2c5 (diff)
downloadgo-tangerine-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.gz
go-tangerine-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.zst
go-tangerine-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.zip
core/types, params: EIP#155
Diffstat (limited to 'core/tx_pool.go')
-rw-r--r--core/tx_pool.go18
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)