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

No duplicate vote inserts with mongodb #1258

Merged
merged 4 commits into from Mar 22, 2017
Merged

Conversation

r-marques
Copy link
Contributor

This pr adds a unique compound index on the votes collection with node_pubkey and vote.voting_for_block. This prevents duplicated votes for the same public key for the same block.

Created and fixed tests.
Removed some unnecessary tests.

@r-marques r-marques requested a review from vrde March 7, 2017 10:19
@r-marques r-marques self-assigned this Mar 7, 2017
@codecov-io
Copy link

codecov-io commented Mar 7, 2017

Codecov Report

Merging #1258 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1258   +/-   ##
=======================================
  Coverage   98.08%   98.08%           
=======================================
  Files          51       51           
  Lines        2295     2295           
=======================================
  Hits         2251     2251           
  Misses         44       44

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9aa243c...a6f2f57. Read the comment docs.

@ssadler
Copy link
Contributor

ssadler commented Mar 20, 2017

This turns out to be kind of critical. A duplicate vote could take a block from being decided to being undecidable. This can't be mitigated by the server, the server can only detect when the database has incorrectly allowed a duplicate vote and throw an error.

@ssadler
Copy link
Contributor

ssadler commented Mar 20, 2017

LGTM

@r-marques r-marques merged commit 10d83c2 into master Mar 22, 2017
@vrde vrde deleted the votes-no-duplicate-inserts branch March 21, 2018 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants