mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#22791: init: Fix asmap/addrman initialization order bug
724c497562[fuzz] Add ConsumeAsmap() function (John Newbery)5840476714[addrman] Make m_asmap private (John Newbery)f9002cb5db[net] Rename the copyStats arg from m_asmap to asmap (John Newbery)f572f2b204[addrman] Set m_asmap in CAddrMan initializer list (John Newbery)593247872d[net] Remove CConnMan::SetAsmap() (John Newbery)50fd77045e[init] Read/decode asmap before constructing addrman (John Newbery) Pull request description: Commit181a1207introduced an initialization order bug: CAddrMan's m_asmap must be set before deserializing peers.dat. The first commit restores the correct initialization order. The remaining commits make `CAddrMan::m_asmap` usage safer: - don't reach into `CAddrMan`'s internal data from `CConnMan` - set `m_asmap` in the initializer list and make it const - make `m_asmap` private, and access it (as a reference to const) from a getter. This ensures that peers.dat deserialization must happen after setting m_asmap, since m_asmap is set during CAddrMan construction. ACKs for top commit: mzumsande: Tested ACK724c497562amitiuttarwar: code review but utACK724c497562naumenkogs: utACK724c497562vasild: ACK724c497562MarcoFalke: review ACK724c497562👫 Tree-SHA512: 684a4cf9e3d4496c9997fb2bc4ec874809987055c157ec3fad1d2143b8223df52b5a0af787d028930b27388c8efeba0aeb2446cb35c337a5552ae76112ade726
This commit is contained in:
@@ -98,10 +98,11 @@ double CAddrInfo::GetChance(int64_t nNow) const
|
||||
return fChance;
|
||||
}
|
||||
|
||||
CAddrMan::CAddrMan(bool deterministic, int32_t consistency_check_ratio)
|
||||
CAddrMan::CAddrMan(std::vector<bool> asmap, bool deterministic, int32_t consistency_check_ratio)
|
||||
: insecure_rand{deterministic}
|
||||
, nKey{deterministic ? uint256{1} : insecure_rand.rand256()}
|
||||
, m_consistency_check_ratio{consistency_check_ratio}
|
||||
, m_asmap{std::move(asmap)}
|
||||
{
|
||||
for (auto& bucket : vvNew) {
|
||||
for (auto& entry : bucket) {
|
||||
|
||||
Reference in New Issue
Block a user