@@ -340,6 +340,7 @@ friend class CAddrManTest;
340
340
* * for each bucket:
341
341
* * number of elements
342
342
* * for each element: index
343
+ * * asmap checksum
343
344
*
344
345
* 2**30 is xorred with the number of buckets to make addrman deserializer v0 detect it
345
346
* as incompatible. This is necessary because it did not check the version number on
@@ -348,8 +349,8 @@ friend class CAddrManTest;
348
349
* Notice that vvTried, mapAddr and vVector are never encoded explicitly;
349
350
* they are instead reconstructed from the other information.
350
351
*
351
- * vvNew is serialized, but only used if ADDRMAN_UNKNOWN_BUCKET_COUNT didn't change,
352
- * otherwise it is reconstructed as well.
352
+ * vvNew is serialized, but only used if ADDRMAN_NEW_BUCKET_COUNT and the asmap checksum
353
+ * didn't change, otherwise it is reconstructed as well.
353
354
*
354
355
* This format is more complex, but significantly smaller (at most 1.5 MiB), and supports
355
356
* changes to the ADDRMAN_ parameters without breaking the on-disk structure.
@@ -413,13 +414,13 @@ friend class CAddrManTest;
413
414
}
414
415
}
415
416
}
416
- // Store asmap version after bucket entries so that it
417
+ // Store asmap checksum after bucket entries so that it
417
418
// can be ignored by older clients for backward compatibility.
418
- uint256 asmap_version ;
419
+ uint256 asmap_checksum ;
419
420
if (m_asmap.size () != 0 ) {
420
- asmap_version = SerializeHash (m_asmap);
421
+ asmap_checksum = SerializeHash (m_asmap);
421
422
}
422
- s << asmap_version ;
423
+ s << asmap_checksum ;
423
424
}
424
425
425
426
template <typename Stream>
@@ -516,13 +517,13 @@ friend class CAddrManTest;
516
517
}
517
518
}
518
519
519
- uint256 supplied_asmap_version ;
520
+ uint256 supplied_asmap_checksum ;
520
521
if (m_asmap.size () != 0 ) {
521
- supplied_asmap_version = SerializeHash (m_asmap);
522
+ supplied_asmap_checksum = SerializeHash (m_asmap);
522
523
}
523
- uint256 serialized_asmap_version ;
524
+ uint256 serialized_asmap_checksum ;
524
525
if (format >= Format::V2_ASMAP) {
525
- s >> serialized_asmap_version ;
526
+ s >> serialized_asmap_checksum ;
526
527
}
527
528
528
529
for (auto bucket_entry : bucket_entries) {
@@ -531,7 +532,7 @@ friend class CAddrManTest;
531
532
CAddrInfo& info = mapInfo[entry_index];
532
533
int nUBucketPos = info.GetBucketPosition (nKey, true , bucket);
533
534
if (format >= Format::V2_ASMAP && nUBuckets == ADDRMAN_NEW_BUCKET_COUNT && vvNew[bucket][nUBucketPos] == -1 &&
534
- info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS && serialized_asmap_version == supplied_asmap_version ) {
535
+ info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS && serialized_asmap_checksum == supplied_asmap_checksum ) {
535
536
// Bucketing has not changed, using existing bucket positions for the new table
536
537
vvNew[bucket][nUBucketPos] = entry_index;
537
538
info.nRefCount ++;
0 commit comments