Skip to content

Conversation

jtimon
Copy link
Contributor

@jtimon jtimon commented Jan 19, 2017

More things to do later with more disruption:

  • The new functions can be turned into static unless someone else has a better idea
  • The documentation should be moved to doxygen
  • An indentation can be done for each of the new function
  • MsgGetData() could be divided in 2, but I don't know if it makes sense

In the spirit of #5153, happy to go further dividing SendMessages in the low disruption territory, rem +13-3

Copy link
Contributor

@JeremyRubin JeremyRubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@@ -2681,6 +2681,9 @@ class CompareInvMempoolOrder
}
};

void MsgGetData(const Consensus::Params& consensusParams, CNode* pto, CConnman& connman, CNetMsgMaker& msgMaker, CNodeState& state, int64_t nNow, bool fFetch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move the declarations (not definitions) to the header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to leave them as static rather than expose them (unless someone else wants to expose some of them later). Perhaps I should have started from the top to avoid the extra declarations. No big deal for me to change it if we decide to divide the whole function ala #9579

@@ -2681,6 +2681,9 @@ class CompareInvMempoolOrder
}
};

void MsgGetData(const Consensus::Params& consensusParams, CNode* pto, CConnman& connman, CNetMsgMaker& msgMaker, CNodeState& state, int64_t nNow, bool fFetch);
void MsgFeeFilter(CNode* pto, CConnman& connman, CNetMsgMaker& msgMaker);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CNetMsgMaker::Make could be const, which might be worth doing to be able to make this reference const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, CNetMsgMaker::Make() is not const :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason why it couldn't be const.

Copy link
Contributor Author

@jtimon jtimon Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I didn't realise both versions of CNetMsgMaker::Make can be just made const too. Very good catch.
Updating both this and #9608.

@fanquake fanquake added the P2P label Jan 19, 2017
@@ -3116,7 +3119,14 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
return true;
}
}
MsgGetData(consensusParams, pto, connman, msgMaker, state, nNow, fFetch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re nNow - Can't it work out the time by itself?

@jtimon
Copy link
Contributor Author

jtimon commented Jan 24, 2017

I would advice reviewers to look at #9608 first, which I should have written first.

@jtimon jtimon force-pushed the 0.15-split-sendmessages branch from b319469 to bb41dab Compare January 24, 2017 00:45
@jtimon jtimon force-pushed the 0.15-split-sendmessages branch from bb41dab to b2d05fa Compare January 31, 2017 23:04
@jtimon
Copy link
Contributor Author

jtimon commented Jan 31, 2017

Rebased on top of #9659 which separates @JeremyRubin 's suggestion and includes a few more similar things.

@jtimon jtimon force-pushed the 0.15-split-sendmessages branch 2 times, most recently from 575aa24 to ab4f51e Compare February 7, 2017 20:42
@jtimon
Copy link
Contributor Author

jtimon commented Feb 7, 2017

Rebased after #9659 has been merged for clarity.

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK ab4f51e


void MsgGetData(const Consensus::Params& consensusParams, CNode* pto, CConnman& connman, const CNetMsgMaker& msgMaker, CNodeState& state, int64_t nNow, bool fFetch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make nNow and fFetch const, to ensure they are not mistakenly updated (and discarded on return) in this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long time ago, I remember I was asked not to do this for basic types. Recently we discussed a PR to change this in the whole codebase (sorry, I can't find it). But good good point, no reason not to do it here and in #9608. It also helps me read functions when more parameters are const.

@jtimon jtimon force-pushed the 0.15-split-sendmessages branch from ab4f51e to 2e4b085 Compare March 6, 2017 22:31
@jtimon
Copy link
Contributor Author

jtimon commented Mar 6, 2017

Fixed nits ( #9608 (comment) #9579 (comment) ) and rebased without needing it.

@jtimon jtimon force-pushed the 0.15-split-sendmessages branch from 2e4b085 to d737d1f Compare April 4, 2017 15:53
More things to do later with more disruption:

- The new functions can be turned into static unless someone else has a better idea
- The documentation should be moved to doxygen
- An indentation can be done for each of the new function
- MsgGetData() could be divided in 2, but I don't know if it makes sense
@jtimon jtimon force-pushed the 0.15-split-sendmessages branch from d737d1f to b2a2ba5 Compare April 5, 2017 23:00
@jtimon
Copy link
Contributor Author

jtimon commented Apr 5, 2017

Rebased just because travis couldn't fetch a file.

@jtimon
Copy link
Contributor Author

jtimon commented Jun 8, 2017

Needed rebase, closing.

@jtimon jtimon closed this Jun 8, 2017
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants