mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +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:
@@ -652,7 +652,7 @@ public:
|
||||
|
||||
void CloseSocketDisconnect();
|
||||
|
||||
void copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap);
|
||||
void CopyStats(CNodeStats& stats, const std::vector<bool>& asmap);
|
||||
|
||||
ServiceFlags GetLocalServices() const
|
||||
{
|
||||
@@ -943,8 +943,6 @@ public:
|
||||
*/
|
||||
std::chrono::microseconds PoissonNextSendInbound(std::chrono::microseconds now, std::chrono::seconds average_interval);
|
||||
|
||||
void SetAsmap(std::vector<bool> asmap) { addrman.m_asmap = std::move(asmap); }
|
||||
|
||||
/** Return true if we should disconnect the peer for failing an inactivity check. */
|
||||
bool ShouldRunInactivityChecks(const CNode& node, std::optional<int64_t> now=std::nullopt) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user