aboutsummaryrefslogtreecommitdiff
path: root/src/primitives/block.h
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-09-09 11:16:31 +0100
committerfanquake <fanquake@gmail.com>2023-09-09 11:30:57 +0100
commit579c49b3a6169469cf53dc7c9eea5ff19b7bf3a4 (patch)
tree3626ed4f671a79aadc03e92867a579e88a6cbb4f /src/primitives/block.h
parent4e1a38c6df91f96ca8a2ef07413ffdb1d59c30cc (diff)
parente73d2a8018def940afadb5d699b18f39e882c1fc (diff)
Merge bitcoin/bitcoin#28428: Hard-code version number value for CBlockLocator and CDiskBlockIndex
e73d2a8018def940afadb5d699b18f39e882c1fc refactor: remove clientversion include from dbwrapper.h (Cory Fields) 4240a082b81d8ceb7615b1b4ca0d2857382f317b refactor: Use DataStream now that version/type are unused (Cory Fields) f15f790618d328abd207d55e6291229eb2a8643f Remove version/hashing options from CBlockLocator/CDiskBlockIndex (Cory Fields) Pull request description: This is also a much simpler replacement for #28327. There are version fields in `CBlockLocator` and `CDiskBlockIndex` that have always been written but discarded when read. I intended to convert them to use SerParams as introduced by #25284, which [ended up looking like this](https://github.com/theuni/bitcoin/commit/3e3af451652322c92e8e41cf918e69d608ec7c77). However because we don't currently have any definition of what a hash value would mean for either one of those, and we've never assigned the version field any meaning, I think it's better to just not worry about them. If we ever need to assign meaning in the future, we can introduce `SerParams` as was done for `CAddress`. As for the dummy values chosen: `CDiskBlockIndex::DUMMY_VERSION` was easy as the highest ever client version, and I don't expect any objection there. `CBlockLocator::DUMMY_VERSION` is hard-coded to the higest _PROTOCOL_ version ever used. This is to avoid a sudden bump that would be visible on the network if CLIENT_VERSION were used instead. In the future, if we ever need to use the value, we can discard anything in the CLIENT_VERSION range (for a few years as needed), as it's quite a bit higher. While reviewing, I suggest looking at the throwaway `SerParams` commit above as it shows where the call-sites are. I believe that should be enough to convince one's self that hashing is never used. ACKs for top commit: TheCharlatan: Re-ACK e73d2a8018def940afadb5d699b18f39e882c1fc ajtowns: reACK e73d2a8018def940afadb5d699b18f39e882c1fc Tree-SHA512: 45b0dd7c2e918493e2ee92a8e35320ad17991cb8908cb811150a96c5fd584ce177c775baeeb8675a602c90b9ba9203b8cefc0a2a0c6a71078b1d9c2b41e1f3ba
Diffstat (limited to 'src/primitives/block.h')
-rw-r--r--src/primitives/block.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/primitives/block.h b/src/primitives/block.h
index 861d362414..99accfc7dd 100644
--- a/src/primitives/block.h
+++ b/src/primitives/block.h
@@ -118,6 +118,15 @@ public:
*/
struct CBlockLocator
{
+ /** Historically CBlockLocator's version field has been written to network
+ * streams as the negotiated protocol version and to disk streams as the
+ * client version, but the value has never been used.
+ *
+ * Hard-code to the highest protocol version ever written to a network stream.
+ * SerParams can be used if the field requires any meaning in the future,
+ **/
+ static constexpr int DUMMY_VERSION = 70016;
+
std::vector<uint256> vHave;
CBlockLocator() {}
@@ -126,9 +135,8 @@ struct CBlockLocator
SERIALIZE_METHODS(CBlockLocator, obj)
{
- int nVersion = s.GetVersion();
- if (!(s.GetType() & SER_GETHASH))
- READWRITE(nVersion);
+ int nVersion = DUMMY_VERSION;
+ READWRITE(nVersion);
READWRITE(obj.vHave);
}