This commit is contained in:
Martin Holst Swende 2017-06-02 22:28:10 +00:00 committed by GitHub
commit a2aab9656e
3 changed files with 12 additions and 3 deletions

View file

@ -40,8 +40,10 @@ import (
type EthApiBackend struct {
eth *Ethereum
gpo *gasprice.Oracle
localNonces map[common.Address] uint64
}
func (b *EthApiBackend) ChainConfig() *params.ChainConfig {
return b.eth.chainConfig
}
@ -160,7 +162,13 @@ func (b *EthApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (
b.eth.txMu.Lock()
defer b.eth.txMu.Unlock()
return b.eth.txPool.State().GetNonce(addr), nil
nonce, _ := b.localNonces[addr]
poolNonce := b.eth.txPool.State().GetNonce(addr)
if poolNonce > nonce{
nonce = poolNonce
}
b.localNonces[addr] = nonce+1
return nonce, nil
}
func (b *EthApiBackend) Stats() (pending int, queued int) {

View file

@ -171,7 +171,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
eth.miner = miner.New(eth, eth.chainConfig, eth.EventMux(), eth.engine)
eth.miner.SetExtra(makeExtraData(config.ExtraData))
eth.ApiBackend = &EthApiBackend{eth, nil}
eth.ApiBackend = &EthApiBackend{eth, nil, make(map[common.Address] uint64)}
gpoParams := config.GPO
if gpoParams.Default == nil {
gpoParams.Default = config.GasPrice

View file

@ -338,7 +338,6 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
}
// Assemble the transaction and sign with the wallet
tx := args.toTransaction()
var chainID *big.Int
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
chainID = config.ChainId
@ -1202,6 +1201,8 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
// Assemble the transaction and sign with the wallet
tx := args.toTransaction()
log.Info("Assembled transaction", "fullhash", tx.Hash().Hex(), "nonce", tx.Nonce())
var chainID *big.Int
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
chainID = config.ChainId