mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06: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
|
||||
}
|
||||
|
||||
// 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
|
||||
func (ms *ManagedState) GetNonce(addr common.Address) uint64 {
|
||||
ms.mu.RLock()
|
||||
|
|
|
|||
|
|
@ -229,8 +229,10 @@ func (self *StateObject) SetCode(code []byte) {
|
|||
}
|
||||
|
||||
func (self *StateObject) SetNonce(nonce uint64) {
|
||||
self.nonce = nonce
|
||||
self.dirty = true
|
||||
if nonce > self.nonce {
|
||||
self.nonce = nonce
|
||||
self.dirty = true
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
b.eth.txMu.Lock()
|
||||
defer b.eth.txMu.Unlock()
|
||||
|
||||
return b.eth.txPool.State().GetNonce(addr), nil
|
||||
return b.eth.txPool.State().GetNextNonce(addr), nil
|
||||
}
|
||||
|
||||
func (b *EthApiBackend) Stats() (pending int, queued int) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue