diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-11-02 20:44:13 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-11-13 21:55:30 +0800 |
commit | 4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188 (patch) | |
tree | 5c55a3088c944ddf517aa4d7c85c5dc7f02d00e4 /light/txpool.go | |
parent | 5cd86443ee071b5e3abe4995c777ce467c29f2c5 (diff) | |
download | go-tangerine-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.gz go-tangerine-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.zst go-tangerine-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.zip |
core/types, params: EIP#155
Diffstat (limited to 'light/txpool.go')
-rw-r--r-- | light/txpool.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/light/txpool.go b/light/txpool.go index c046cac25..309bc3a32 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -44,6 +44,7 @@ var txPermanent = uint64(500) // created. type TxPool struct { config *params.ChainConfig + signer types.Signer quit chan bool eventMux *event.TypeMux events event.Subscription @@ -80,6 +81,7 @@ type TxRelayBackend interface { func NewTxPool(config *params.ChainConfig, eventMux *event.TypeMux, chain *LightChain, relay TxRelayBackend) *TxPool { pool := &TxPool{ config: config, + signer: types.HomesteadSigner{}, nonce: make(map[common.Address]uint64), pending: make(map[common.Hash]*types.Transaction), mined: make(map[common.Hash][]*types.Transaction), @@ -198,7 +200,7 @@ func (pool *TxPool) checkMinedTxs(ctx context.Context, hash common.Hash, idx uin if len(receipts) != len(block.Transactions()) { panic(nil) // should never happen if hashes did match } - core.SetReceiptsData(block, receipts) + core.SetReceiptsData(pool.config, block, receipts) } //fmt.Println("WriteReceipt", receipts[i].TxHash) core.WriteReceipt(pool.chainDb, receipts[i]) @@ -309,6 +311,7 @@ func (pool *TxPool) eventLoop() { m, r := txc.getLists() pool.relay.NewHead(pool.head, m, r) pool.homestead = pool.config.IsHomestead(head.Number) + pool.signer = types.MakeSigner(pool.config, head.Number) pool.mu.Unlock() } } @@ -340,7 +343,7 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error // Validate the transaction sender and it's sig. Throw // if the from fields is invalid. - if from, err = tx.From(); err != nil { + if from, err = types.Sender(pool.signer, tx); err != nil { return core.ErrInvalidSender } @@ -389,7 +392,7 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error } // Should supply enough intrinsic gas - if tx.Gas().Cmp(core.IntrinsicGas(tx.Data(), core.MessageCreatesContract(tx), pool.homestead)) < 0 { + if tx.Gas().Cmp(core.IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead)) < 0 { return core.ErrIntrinsicGas } @@ -413,7 +416,8 @@ func (self *TxPool) add(ctx context.Context, tx *types.Transaction) error { self.pending[hash] = tx nonce := tx.Nonce() + 1 - addr, _ := tx.From() + + addr, _ := types.Sender(self.signer, tx) if nonce > self.nonce[addr] { self.nonce[addr] = nonce } @@ -433,7 +437,7 @@ func (self *TxPool) add(ctx context.Context, tx *types.Transaction) error { } // we can ignore the error here because From is // verified in ValidateTransaction. - f, _ := tx.From() + f, _ := types.Sender(self.signer, tx) from := common.Bytes2Hex(f[:4]) glog.Infof("(t) %x => %s (%v) %x\n", from, toname, tx.Value, hash) } @@ -518,7 +522,7 @@ func (self *TxPool) Content() (map[common.Address]types.Transactions, map[common // Retrieve all the pending transactions and sort by account and by nonce pending := make(map[common.Address]types.Transactions) for _, tx := range self.pending { - account, _ := tx.From() + account, _ := types.Sender(self.signer, tx) pending[account] = append(pending[account], tx) } // There are no queued transactions in a light pool, just return an empty map |