Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockchain: fix a bug where a duplicate entry is possible in the mapslice #2134

Conversation

kcalvinalvin
Copy link
Collaborator

Adds a test and fixes the bug to fix a case where a duplicate entry in the mapslice is possible.

Not sure if this is related to the other cases we've been seeing since the outpoints should never have duplicates, fixing this is good since the code is assuming that the mapslice will not have duplicates.

Duplicate entries are currently possible in the following scenario:

1: Add entries to the mapslice.
2: 1st map is full. Move onto the 2nd map.
3: Delete any entry in the first map.
4: Attempt to add an entry in the 2nd map.

When attempting (4), the entry should just be overwritten but a
duplicate gets added.
When attempting to insert an entry to the mapslice, we check all the
underlying maps to ensure that the entry doesn't exist.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8184106558

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 56.771%

Files with Coverage Reduction New Missed Lines %
mempool/mempool.go 1 66.84%
peer/peer.go 5 74.16%
Totals Coverage Status
Change from base Build 8160957537: 0.01%
Covered Lines: 29295
Relevant Lines: 51602

💛 - Coveralls

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🛺

@Roasbeef Roasbeef merged commit 8ed234b into btcsuite:master Mar 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants