Init should only concern itself with the initialization order, not the detailed initialization logic of every module.
Discussed in #22697 (review)
Init should only concern itself with the initialization order, not the detailed initialization logic of every module.
Discussed in #22697 (review)
735@@ -733,3 +736,22 @@ std::vector<bool> CAddrMan::DecodeAsmap(fs::path path)
736 }
737 return bits;
738 }
739+
740+void LoadAddrman(std::unique_ptr<CAddrMan>& addrman, const ArgsManager& args)
741+{
742+ assert(!addrman);
std::unique_ptr<CAddrMan>
? (or an optional, if it can fail, but doesn’t seem so). Passing it in then asserting seems unnecessary.
742+ assert(!addrman);
743+ auto check_addrman = std::clamp<int32_t>(args.GetArg("-checkaddrman", DEFAULT_ADDRMAN_CONSISTENCY_CHECKS), 0, 1000000);
744+ addrman = std::make_unique<CAddrMan>(/* deterministic */ false, /* consistency_check_ratio */ check_addrman);
745+
746+ // Load addresses from peers.dat
747+ int64_t nStart = GetTimeMillis();
nit, if you retouch
0 const int64_t nStart{GetTimeMillis()};
Init should only concern itself with the initialization order, not the
detailed initialization logic of every module.
AppInitMain()
is doing, rather than just hiding it behind a function call.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
I don’t see why init.cpp needs to include all existing headers to learn about the implementation details of each module to initialize them.
This PR doesn’t reduce the number of headers that init.cpp includes (and I also don’t think it’s a problem for init to include lots of headers - after all, it’s init’s job to start everything up so it needs to include the headers for all the submodules).
Just like wallet initialization and block importing was moved out, I think the address database details can be moved out as well.
The difference with wallet initialization and block importing is that those are internal to the wallet and validation modules. Addrman initialization from peers.dat is something that’s being done to a CAddrMan externally, even after this PR.
To be clear, I don’t object to this and I’m certainly not NACKing, I just don’t think it brings much benefit.