aboutsummaryrefslogtreecommitdiffstats
path: root/light/txpool.go
diff options
context:
space:
mode:
Diffstat (limited to 'light/txpool.go')
-rw-r--r--light/txpool.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/light/txpool.go b/light/txpool.go
index 825a0f909..309bc3a32 100644
--- a/light/txpool.go
+++ b/light/txpool.go
@@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"golang.org/x/net/context"
)
@@ -42,7 +43,8 @@ var txPermanent = uint64(500)
// always receive all locally signed transactions in the same order as they are
// created.
type TxPool struct {
- config *core.ChainConfig
+ config *params.ChainConfig
+ signer types.Signer
quit chan bool
eventMux *event.TypeMux
events event.Subscription
@@ -76,9 +78,10 @@ type TxRelayBackend interface {
}
// NewTxPool creates a new light transaction pool
-func NewTxPool(config *core.ChainConfig, eventMux *event.TypeMux, chain *LightChain, relay TxRelayBackend) *TxPool {
+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),
@@ -197,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])
@@ -308,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()
}
}
@@ -339,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
}
@@ -388,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
}
@@ -412,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
}
@@ -432,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)
}
@@ -517,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