core: fix write concurrency in txpool#19835
Merged
karalabe merged 3 commits intoethereum:masterfrom Jul 17, 2019
Merged
Conversation
fjl
reviewed
Jul 16, 2019
| func (pool *TxPool) Nonce(addr common.Address) uint64 { | ||
| pool.mu.RLock() | ||
| defer pool.mu.RUnlock() | ||
|
|
Contributor
There was a problem hiding this comment.
pool.pendingNonces is set in pool.reset(...).
Member
Author
|
@fjl done |
karalabe
reviewed
Jul 17, 2019
|
|
||
| // compareAndSet inserts or updates a new virtual nonce into the virtual state | ||
| // database if the compare callback is true. | ||
| func (txn *txNoncer) compareAndSet(addr common.Address, nonce uint64, compare func(uint64, uint64) bool) { |
Member
There was a problem hiding this comment.
Passing a compare method in here seems really convoluted, especially since all instances use the same logic anyway. Let's just rename compareAndSet to setIfLower, get rid of compare altogether and do the comparison internally.
Member
Author
|
@karalabe Fixed, please take another look. |
19 tasks
gzliudan
added a commit
to gzliudan/XDPoSChain
that referenced
this pull request
May 10, 2024
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19834