Removes a bunch of redundant, dead or duplicate code.
Uses the idea from and finishes the idea #28428 by theuni
GetType() is never called, so it is completely unused and can be
removed.
The type is only ever set, but never read via GetType(), so remove it.
Also, remove SerializeHash to avoid silent merge conflicts and use the
already existing GetHash() boilerplate consistently.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | kevkevinpal, ajtowns |
| Concept ACK | theuni, stickies-v |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Concept ACK.
Mind splitting up the last commit? The version number change needs a bit of scrutiny imo, but it's hidden inside an innocuous commit message.
Changed the commit title and PR title. Is it good enough?
It was never set, so it can be removed along with any code reading it.
81 | {
82 | if (!HasWitness()) {
83 | return hash;
84 | }
85 | - return SerializeHash(*this, SER_GETHASH, 0);
86 | + return (CHashWriter{0} << *this).GetHash();
CHashWriter{0} is pretty ugly. I assume this will be going away though as part of one of the other refactors going on?
Yes, it will become HashWriter{}
122 | @@ -123,20 +123,14 @@ class CKeyPool 123 | template<typename Stream> 124 | void Serialize(Stream& s) const 125 | { 126 | - int nVersion = s.GetVersion(); 127 | - if (!(s.GetType() & SER_GETHASH)) { 128 | - s << nVersion; 129 | - } 130 | + s << int{259900}; // Unused field, writes the highest client version ever written
nit: in the comment does "highest client version ever written" mean that this is the highest client version that can be written or that we've ever seen written?
Suggestion "Unused field, writes the highest possible client version"
feel free to ignore this nit aswell!
It is the current client version written. It should be possible to confirm this by adding an std::cout << nVersion << "\n"; here.
The client version is only increased, so it is also the highest.
In any case, the value doesn't matter, so I am happy to replace it with anything else.
added one nit but otherwise ACK fac29a0
Concept ACK
ACK fac29a0ab19fda457b55d7a0a37c5cd3d9680f82