[Refactoring] Remove BaseOutPoint::GetHash#2180
Merged
Merged
Conversation
- nHash is supposed to be the vote hash, not the outpoint hash - mnId is the collateral outpoint (not just the outpoint.hash)
These functions are supposed to return a vector of vote-hashes. They instead return a vector of mnIds(collateral)-hashes.
instead of using the hash of the whole outpoint object.
|
Concept ACK 👌 |
furszy
approved these changes
Feb 16, 2021
Fuzzbawls
approved these changes
Feb 19, 2021
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.
BaseOutPointhas a member variable namedhash, butGetHash()does not return its value.It returns the hash of the serialized class (
hashandn) instead.This is confusing and might lead to sneaky bugs (in fact, it already did in the past: #1963 (comment))
Further, the implementation of
GetHash()is rather ugly, as it accesses the singleton pointer&this->nas an array (withBEGIN()/END()), which could result in misinterpretation or corruption of adjacent memory locations.This function is used only in two places:
getbudgetvotesfor the key"nHash". This is wrong, as nHash is supposed to be the vote hash (as described in the help), and not the collateral outpoint hash.mapVotesinside budgets and proposal objects. Here we can just index directly by collateral outpoint (instead of its hash).With these two changes, we can get rid of
BaseOutPoint::GetHash.This also fixes another bug fund along the way:
CBP/CFB::GetVotesHashesshould return the vote hashes, not the masternode collateral hash.Note:
mapVotesis not directly sent on the network, it is only stored locally for each proposal.