MarcoFalke a8fdfea77b
Merge bitcoin/bitcoin#22791: init: Fix asmap/addrman initialization order bug
724c4975622bc22cedc3f3814dfc8e66cf8371f7 [fuzz] Add ConsumeAsmap() function (John Newbery)
5840476714ffebb2599999c85a23b52ebcff6090 [addrman] Make m_asmap private (John Newbery)
f9002cb5dbd573cd9ca200de21319fa296e26055 [net] Rename the copyStats arg from m_asmap to asmap (John Newbery)
f572f2b2048994b3b50f4cfd5de19e40b1acfb22 [addrman] Set m_asmap in CAddrMan initializer list (John Newbery)
593247872decd6d483a76e96d79433247226ad14 [net] Remove CConnMan::SetAsmap() (John Newbery)
50fd77045e2f858a53486b5e02e1798c92ab946c [init] Read/decode asmap before constructing addrman (John Newbery)

Pull request description:

  Commit 181a1207 introduced 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 ACK 724c4975622bc22cedc3f3814dfc8e66cf8371f7
  amitiuttarwar:
    code review but utACK 724c497562
  naumenkogs:
    utACK 724c4975622bc22cedc3f3814dfc8e66cf8371f7
  vasild:
    ACK 724c4975622bc22cedc3f3814dfc8e66cf8371f7
  MarcoFalke:
    review ACK 724c4975622bc22cedc3f3814dfc8e66cf8371f7 👫

Tree-SHA512: 684a4cf9e3d4496c9997fb2bc4ec874809987055c157ec3fad1d2143b8223df52b5a0af787d028930b27388c8efeba0aeb2446cb35c337a5552ae76112ade726
2021-09-06 12:41:36 +02:00
..
2021-07-30 11:21:51 +02:00
2021-07-30 11:21:51 +02:00
2021-03-17 17:59:22 -07:00
2021-03-17 17:59:22 -07:00
2021-06-03 13:53:31 +02:00
2021-08-26 10:44:26 +02:00
2021-07-30 11:24:59 +02:00
2021-04-06 14:50:17 +08:00
2021-08-23 21:38:34 -04:00