Merge #19822: chain: Fix CChain comparison UB by removing it (it was unused)

df536883d2 chain: Remove UB CChain comparison (Carl Dong)

Pull request description:

  Comparing two empty `CChain`s is currently undefined behaviour, and resulted in false assertion failures when comparing identical empty `CChain`s in local testing.

  Let's just remove this comparison operator since it doesn't seem to be used anywhere.

ACKs for top commit:
  practicalswift:
    ACK df536883d2 -- patch is guaranteed to be correct :)
  MarcoFalke:
    cr ACK df536883d2

Tree-SHA512: db10bac364fc965b56abf7a5bac48018786b14806ffe107e3e8eb24d5004a29331f3387dfe3409a3452a6750d3329e3f354265d787ebb3abfccabe77b28a54d5
pull/764/head
fanquake 4 years ago
commit 4326515f01
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

@ -398,12 +398,6 @@ public:
return vChain[nHeight]; return vChain[nHeight];
} }
/** Compare two chains efficiently. */
friend bool operator==(const CChain &a, const CChain &b) {
return a.vChain.size() == b.vChain.size() &&
a.vChain[a.vChain.size() - 1] == b.vChain[b.vChain.size() - 1];
}
/** Efficiently check whether a block is present in this chain. */ /** Efficiently check whether a block is present in this chain. */
bool Contains(const CBlockIndex *pindex) const { bool Contains(const CBlockIndex *pindex) const {
return (*this)[pindex->nHeight] == pindex; return (*this)[pindex->nHeight] == pindex;

Loading…
Cancel
Save