Skip to content

Conversation

@random-zebra
Copy link

@random-zebra random-zebra commented Jun 29, 2021

This is a collection of simple refactorings coming from upstream Bitcoin v0.16 (adapting/extending to PIVX-specific code where needed).

Pull requests backported:

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a 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)

@random-zebra
Copy link
Author

Rebased on master, fixing minor conflict.

As for all the comments related to MakeUnique, I've scripted the change and removed util/memory.h in #2467 .
We can do it anytime.

@random-zebra
Copy link
Author

random-zebra commented Jul 2, 2021

Note that this includes a commit cherry-picked in #2423 too (65590a69224e595c24b0919ca528970570364561). Will drop it if #2423 is merged before this one.

EDIT: removed

@random-zebra random-zebra force-pushed the 202106_refactor-btc-0.16 branch from 25da71c to 6721277 Compare July 22, 2021 11:35
furszy
furszy previously approved these changes Jul 22, 2021
Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Code review ACK 67212778b0d1cf0d11d118f6cc0013fd378c6713 .

good overall updates 👍. This will conflicts a bit with #2411 and #2480 as well (net area), hopefully will not be hard to rebase for any of us.

@random-zebra
Copy link
Author

Rebased again. let's get this merged

furszy
furszy previously approved these changes Jul 24, 2021
Copy link

@furszy furszy left a 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

random-zebra and others added 20 commits July 25, 2021 20:54
>>> adapts bitcoin/bitcoin@d223bc9

* pcoinscatcher (CCoinsViewErrorCatcher)
* pcoinsdbview (CCoinsViewDB)
* pcoinsTip (CCoinsViewCache)
* pblocktree (CBlockTreeDB)
* Remove variables shadowing pcoinsdbview

--- PIVX:
use unique_ptr also for
* zerocoinDB
* pSporkDB
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().
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
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK 7a5d181

Copy link

@furszy furszy left a 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..

@furszy furszy merged commit 60d3629 into PIVX-Project:master Jul 26, 2021
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Jul 27, 2021
…_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.