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);
Maybe return std::unique_ptr<CAddrMan>? (or an optional, if it can fail, but doesn't seem so). Passing it in then asserting seems unnecessary.
Done
Concept ACK
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
const int64_t nStart{GetTimeMillis()};
Done
Concept ACK
Init should only concern itself with the initialization order, not the
detailed initialization logic of every module.
I'm ~0 on this change. I don't think there's any real benefit in moving this initialization code from init.cpp to a free function in addrdb.cpp that gets called by init. That doesn't seem to me to be reducing the complexity of what AppInitMain() is doing, rather than just hiding it behind a function call.
init.cpp is almost 2000 lines of code. 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. Just like wallet initialization and block importing was moved out, I think the address database details can be moved out as well.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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.
As this is required for some other changes, I am just going to bundle with them.