Skip to content

Commit

Permalink
Merge pull request ethereum#46 from bts/quorum-managed-state-concurre…
Browse files Browse the repository at this point in the history
…nt-write-fix

state: take write lock in GetNonce
  • Loading branch information
jpmsam authored Feb 2, 2017
2 parents c90f8af + 65a8d80 commit e521fa0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/state/managed_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 {
return uint64(len(account.nonces)-1) + account.nstart
}

// GetNonce returns the canonical nonce for the managed or unmanaged account
// GetNonce returns the canonical nonce for the managed or unmanaged account.
//
// Because GetNonce mutates the DB, we must take a write lock.
func (ms *ManagedState) GetNonce(addr common.Address) uint64 {
ms.mu.RLock()
defer ms.mu.RUnlock()
ms.mu.Lock()
defer ms.mu.Unlock()

if ms.hasAccount(addr) {
account := ms.getAccount(addr)
Expand Down

0 comments on commit e521fa0

Please sign in to comment.