-
Notifications
You must be signed in to change notification settings - Fork 38.7k
MOVEONLY-ish: Do not include main.h from any other header #5681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Very nice, I've been meaning to take a look at this as well. Great to see it was relatively non-invasive. utAck. |
|
ACK. Looks like a definite improvement to me, and low-risk due to (mostly) move only. It becomes kind of apparent from this how much is exported in main.h that
(a) could be reduced by factoring the initialization and shutdown sequences from init.cpp and moving them with what is initiialized @sipa may want to weigh in here too as he has specific ideas about refactoring main. |
|
For b and c, maybe a half-solution that just comes to mind, is just leaving the definitions in main.cpp but expose them with an independent header like main_test.h or something. Just a random thought. I'm basically focusing on consensus and policy checks. Trying to take advantage of potential similarities between their dependencies. Right now it's kind of a mess that doesn't even pass the tests, but if you're curious, here's my latest branch on that: https://github.com/jtimon/bitcoin/commits/consensus_policy |
|
Pretty cool, that you are following the ordering style still ^^. Does this also speedup compilation times, did you benchmark it? |
|
@Diapolo thanks for double-checking the include alphabetical order. |
|
I left the final commit cleaning up the includes for later. |
|
Needed rebase. |
|
Needed rebase. I added a commit to not include main.h from any other header again, but it's not a big and exhaustive cleanup as it was at the beginning. I still leave that for #5697 after more code movements. |
|
ut ACK, assuming travis is happy tomorrow. Verified that the MOVEONLY commits are still move only. |
|
ACK. Could you please give this a quick bump for travis, though? There were some caching issues that have been long-fixed. |
810beb7 to
02613e6
Compare
|
Changed the last commit's id to give travis another try as demanded by @theuni |
|
s/demanded by/humbly requested by/ :) All green now, thanks. |
|
Sure, humbly requested, thanks for the review and ack. |
|
ping |
|
The first commit doesn't make sense to me: CNodeStateStats is statistics of CNodeState, which is a main-specific data structure. Moving it up to a higher layer (net) seems wrong. |
|
How is net.o is higher level than main.o? main.cpp depends on net and not the other way around... |
|
Maybe my terminology is confused. I mean main is a client of net, building on top of it. Net should not know anything about what its clients do. CNodeStateStats is stats about CNodeState, the message processing specific data structure about nodes. Message processing is done in main, so this data structure definition belongs there and nowhere else. Don't get me wrong: the current placing of code in main and net is terrible, but we shouldn't hack around that. Message processing needs to be split up, and moved out to separate modules, and the related data structures with it. |
|
Rebased without the first commit as suggested by @sipa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's sad, we should move that elsewhere (not a criticism on your PR, just noticing).
|
Untested ACK. |
|
utACK. I'd like to see the node info moved out as well, but that makes sense to do separately. |
|
Needed rebase, I also slightly improved the includes. |
|
@jtimon No specific reason, just a overload of pulls caused me to lose track of this one for a while, sorry for that. |
Moving some code, including main.h from qt/peertablemodel.h and wallet.h can be avoided.
Also, main.h doesn't need to include many things that can be included in main.cpp.
After that, using the compiler to make sure only files that depend on main.h include it, many missing includes show up.
Many files should require less memory for being compiled after this.