-
Notifications
You must be signed in to change notification settings - Fork 45
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
There was repeated hashing happening #25
base: 2.0
Are you sure you want to change the base?
Conversation
…p ProcessBlock -> AcceptBlock calls each did a GetHash. Changed GetHash to only compute on the first call to GetHash and store in memory only the hash (If ever loaded it would have to hash again) Using mutable on those objects to acomplish this so not sure if I am breaking code practices
i'll run this through the gauntlet of tests this week, thanks |
cool |
I know this PR was submitted ages ago, but I'm trying to update the MintCoin wallet a bit and so looking through these old PR. Anyway, I kind of like the approach here, which I take to be a kind of memoization. There are a couple of problems with the specific implementation though. The first problem is that the The second problem is that the members of this class are public, and so can be changed. If that happens, then the resulting saved hash is no longer the same. If we return the saved hash, then it will be wrong. It is possible that this never happens with the way the code is today, but we have no easy way to know (I am too lazy to read all of the code to check for it, and would not trust that I had not missed it). Also, a future change to the code might unintentionally break things; there are reasons that we have public/private distinctions. 😉 I have two possible approaches that can resolve this problem:
...
inline unsigned int get_nTime() { return nTime; }
inline void set_nTime(unsigned int new_nTime) { if (nTime != new_nTime) { bComputedHash = false; nTime = new_nTime; } }
... With this second approach we can invalidate the hash if any of the members of an instance change, insuring that we only use the saved version if it is still valid. It is definitely more work and would require a lot of changes (although honestly the code should have been designed this way in the first place). I don't know if you're still interested in this work or not. I am happy to work with you or even make the changes myself. I appreciate the effort you have taken! |
warnings on Qt wallet start #20
One case is during the bootstrap ProcessBlock -> AcceptBlock calls each did a GetHash. Changed GetHash to only compute on the first call to GetHash and store in memory only the hash (If ever loaded it would have to hash again) Using mutable on those objects to accomplish this so not sure if I am breaking code practices.
Tested by looking at LoadExternalBlockFile and every 500 blocks printed (total elapsed time/ nloaded) in ms