-
Notifications
You must be signed in to change notification settings - Fork 725
[Refactoring] Bitcoin 0.16 cherries #2462
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
[Refactoring] Bitcoin 0.16 cherries #2462
Conversation
Fuzzbawls
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial review: noticed some new introductions of our own MakeUnique wrapper, which was required prior to requiring c++14. Since we now require c++14 though, it doesn't make much sense to continue using the MakeUnique wrapper in new/changed code when we can instead use std::make_unique directly.
We still use the MakeUnique wrapper elsewhere in the codebase though, so if you want to leave it as-is in this PR, I can do a follow-up PR afterwards that switches all instances over to std::make_unique via a scripted-diff and removes the wrapper entirely (which is what upstream ultimately did)
4032ed0 to
25da71c
Compare
|
Rebased on master, fixing minor conflict. As for all the comments related to |
25da71c to
6721277
Compare
furszy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6721277 to
350749d
Compare
|
Rebased again. let's get this merged |
furszy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Walked through the PR again, rebase utACK 350749d469bc0bbb28bb9be075442111865926be
1. nStatus of CBlockIndex is consistent with the definition of Enum(BlockStatus) 2. The BlockHeader is consistent with the type of variable defined in CBlockHeader
Plus a use of std::copy() instead of manual copying.
>>> adaptation of bitcoin/bitcoin@58d91af
return false >>> backports bitcoin/bitcoin@b296bf1
>>> adapts bitcoin/bitcoin@d223bc9 * pcoinscatcher (CCoinsViewErrorCatcher) * pcoinsdbview (CCoinsViewDB) * pcoinsTip (CCoinsViewCache) * pblocktree (CBlockTreeDB) * Remove variables shadowing pcoinsdbview --- PIVX: use unique_ptr also for * zerocoinDB * pSporkDB
>>> backports bitcoin/bitcoin@3e09b39 +bitcoin@a357293
std::unordered_map::erase( const_iterator pos ) returns an iterator to the element following the removed one. Use that to optimize (probably minor-performance-wise, and definitely code-structure-wise) the implementation of CCoinsViewCache::BatchWrite().
(remove "enum hack")
Move to AppInitServers. This doesn't have any effects on bitcoin behavior. It was just strange to have this unrelated code in the middle or parameter interaction.
Before this commit:
for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) {
}
After this commit:
for (auto& x : y) {
}
Make the non-const overload of CBlockIndex::GetAncestor() reuse the const overload implementation instead of the other way around. This way, the constness of the const overload implementation is guaranteed. The other way around, it was possible to implement the non-const overload in a way which mutates the object, and since that implementation would be called even for const objects (due to the reuse), we would get undefined behavior.
…+/- 1 byte for HMAC-SHA256 and 128 bytes +/- 1 byte for HMAC-SHA512
>>> adapts bitcoin/bitcoin@a720b92 Remove includes in .cpp files for things the corresponding .h file already included
std::string::find has a character based overload as can be seen here (4th oveload): http://www.cplusplus.com/reference/string/string/find/ Use that instead of constantly allocating temporary strings.
350749d to
7a5d181
Compare
Fuzzbawls
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 7a5d181
furszy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 7a5d181 after rebase, no code changes. Merging..
…_unique (C++14) 68a36a3 [Cleanup] Remove no longer needed util/memory.h (random-zebra) 24b0f73 scripted-diff: replace MakeUnique with std::make_unique (random-zebra) Pull request description: Also remove `util/memory.h` and relative header includes. As suggested by @Fuzzbawls in PIVX-Project#2462 (review). Based on top of - [x] PIVX-Project#2462 ACKs for top commit: furszy: utACK 68a36a3 Fuzzbawls: ACK 68a36a3 Tree-SHA512: 4dffacd07ffa24918a91f141e03838c6deb8e448f3cff0dfe0adbbb014e10568ff58bc0828ba8950d05ef4908a4d860f8755d1fa12df57192255a429b32bd605
This is a collection of simple refactorings coming from upstream Bitcoin v0.16 (adapting/extending to PIVX-specific code where needed).
Pull requests backported:
Refactor: Modernize disallowed copy constructors/assignment bitcoin/bitcoin#11351 (danra)[edit: removed - included in [Wallet] Introduce wallets directory configuration and external wallet files capabilities #2423]