mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
Terrible horrible no good very bad fix for #2950
This commit is contained in:
parent
5fc032a9d1
commit
1ad27dbb4f
3 changed files with 22 additions and 6 deletions
|
|
@ -82,6 +82,23 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 {
|
||||||
return uint64(len(account.nonces)-1) + account.nstart
|
return uint64(len(account.nonces)-1) + account.nstart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNextNonce returns the canonical nonce for the managed or unmanaged account and increments it by one
|
||||||
|
func (ms *ManagedState) GetNextNonce(addr common.Address) uint64 {
|
||||||
|
ms.mu.Lock()
|
||||||
|
defer ms.mu.Unlock()
|
||||||
|
|
||||||
|
var nonce uint64
|
||||||
|
|
||||||
|
if ms.hasAccount(addr) {
|
||||||
|
account := ms.getAccount(addr)
|
||||||
|
nonce = uint64(len(account.nonces)) + account.nstart
|
||||||
|
} else {
|
||||||
|
nonce = ms.StateDB.GetNonce(addr)
|
||||||
|
}
|
||||||
|
ms.StateDB.SetNonce(addr, nonce+1)
|
||||||
|
return nonce
|
||||||
|
}
|
||||||
|
|
||||||
// GetNonce returns the canonical nonce for the managed or unmanaged account
|
// GetNonce returns the canonical nonce for the managed or unmanaged account
|
||||||
func (ms *ManagedState) GetNonce(addr common.Address) uint64 {
|
func (ms *ManagedState) GetNonce(addr common.Address) uint64 {
|
||||||
ms.mu.RLock()
|
ms.mu.RLock()
|
||||||
|
|
|
||||||
|
|
@ -229,8 +229,10 @@ func (self *StateObject) SetCode(code []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateObject) SetNonce(nonce uint64) {
|
func (self *StateObject) SetNonce(nonce uint64) {
|
||||||
|
if nonce > self.nonce {
|
||||||
self.nonce = nonce
|
self.nonce = nonce
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateObject) Nonce() uint64 {
|
func (self *StateObject) Nonce() uint64 {
|
||||||
|
|
|
||||||
|
|
@ -136,10 +136,7 @@ func (b *EthApiBackend) GetPoolTransaction(txHash common.Hash) *types.Transactio
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) {
|
func (b *EthApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) {
|
||||||
b.eth.txMu.Lock()
|
return b.eth.txPool.State().GetNextNonce(addr), nil
|
||||||
defer b.eth.txMu.Unlock()
|
|
||||||
|
|
||||||
return b.eth.txPool.State().GetNonce(addr), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthApiBackend) Stats() (pending int, queued int) {
|
func (b *EthApiBackend) Stats() (pending int, queued int) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue