Skip to content
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

net: Add and document network messages in protocol.h #7181

Merged
merged 1 commit into from Dec 11, 2015

Conversation

@laanwj
Copy link
Member

laanwj commented Dec 7, 2015

  • Avoids string typos (by making the compiler check).
  • Makes it easier to grep for handling/generation of a certain message type.
  • Refer directly to documentation by following the symbol in IDE or doxygen.
  • Make sure we have an overview of all handled/emitted messages, for functionality like #6589.

@harding I've used your descriptions of the message types, hope you don't mind :)

Edit: sendheaders is not yet documented in the developer docs, this is tracked here: bitcoin-dot-org/bitcoin.org#1153

@laanwj laanwj added Docs P2P labels Dec 7, 2015
@laanwj
Copy link
Member Author

laanwj commented Dec 7, 2015

@jonasschnelli second commit moves your logAllowIncomingMsgCmds to protocol.cpp, I think this makes sense to have everything related to message types together.

@laanwj laanwj force-pushed the laanwj:2015_12_network_messages branch 2 times, most recently Dec 7, 2015
@@ -140,3 +172,9 @@ std::string CInv::ToString() const
{
return strprintf("%s %s", GetCommand(), hash.ToString());
}

This comment has been minimized.

Copy link
@GIJensen

GIJensen Dec 7, 2015

Is this double newline supposed to be here? I noticed it earlier in the file too (unrelated to this change).

This comment has been minimized.

Copy link
@laanwj

laanwj Dec 7, 2015

Author Member

No ,not on purpose, will remove it

@jonasschnelli
Copy link
Member

jonasschnelli commented Dec 7, 2015

Careful Code Review ACK.
Nice. This change was long overdue!

@GIJensen
Copy link

GIJensen commented Dec 7, 2015

utACK, I was thinking about how we needed this today!

@laanwj laanwj force-pushed the laanwj:2015_12_network_messages branch Dec 7, 2015
@paveljanik
Copy link
Contributor

paveljanik commented Dec 7, 2015

ACK

@jgarzik
Copy link
Contributor

jgarzik commented Dec 7, 2015

ut ACK

Cosmetic nit: It would be nice to break up allNetMessageTypes[] into one-per-line in the source code, permitting a more simple future patch of

 + NET_MSG_MYNEWMSG,

versus

 - NET_MSG_A, NET_MSG_B, NET_MSG_C, NET_MSG_D
 + NET_MSG_A, NET_MSG_B, NET_MSG_MYNEWMSG, NET_MSG_C, NET_MSG_D

for future patch readability and simplicity.

@pstratem
Copy link
Contributor

pstratem commented Dec 7, 2015

er... why?

@harding
Copy link
Member

harding commented Dec 8, 2015

Note, PR bitcoin-dot-org/bitcoin.org#1154 has been opened in the Bitcoin.org repository to add brief sendheaders documentation at the URL referenced in this PR. Thanks!

@dcousens
dcousens reviewed Dec 8, 2015
View changes
src/protocol.cpp Outdated
NET_MSG_NOTFOUND, NET_MSG_FILTERLOAD, NET_MSG_FILTERADD, NET_MSG_FILTERCLEAR, NET_MSG_REJECT,
NET_MSG_SENDHEADERS
};
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));

This comment has been minimized.

Copy link
@dcousens

dcousens Dec 8, 2015

Contributor

1 day, initializer lists.

@dcousens
Copy link
Contributor

dcousens commented Dec 8, 2015

utACK f5b1d97 (and verified consistent constant usage).

Agreed this will make grepping way easier, plus it documents each command with clear entry points for new features etc.

@laanwj
Copy link
Member Author

laanwj commented Dec 8, 2015

er... why?

Is there anything unclear from the opening post?
If you really want to know the secret reason is: "makes maintenance for me easier".

Cosmetic nit: It would be nice to break up allNetMessageTypes[] into one-per-line in the source code, permitting a more simple future patch of

Makes sense.

@laanwj laanwj force-pushed the laanwj:2015_12_network_messages branch Dec 8, 2015
@laanwj
Copy link
Member Author

laanwj commented Dec 8, 2015

Rebased and squashed after #7180

@laanwj
Copy link
Member Author

laanwj commented Dec 8, 2015

@theuni Hope this doesn't collide with your P2P work?

@laanwj
Copy link
Member Author

laanwj commented Dec 8, 2015

Any opinion on putting the constants in a namespace instead of NET_MSG_ prefix?
NET_MSG_SENDHEADERS would become e.g. NetMsgType::SENDHEADERS. This is syntactically more in line with C++11 strongly typed enumerations.
(could make it an actual enumeration at some point provided something else does conversion from/to string, which would make comparison/switching easier, but that's not the goal here)

@paveljanik
Copy link
Contributor

paveljanik commented Dec 8, 2015

+1!

@jonasschnelli
Copy link
Member

jonasschnelli commented Dec 8, 2015

Agree with using a namespace instead of the NET_MSG_ prefix.

@pstratem
Copy link
Contributor

pstratem commented Dec 8, 2015

@laanwj hmm ok

utACK 399551f2c246844f8a8c4994142c6e04bf283778

@jgarzik
Copy link
Contributor

jgarzik commented Dec 9, 2015

@laanwj Yes - we should start using namespaces. IMO first step is Bitcoin:: and second step is Net:: under that.

@dcousens
Copy link
Contributor

dcousens commented Dec 9, 2015

reACK 399551f

- Avoids string typos (by making the compiler check)
- Makes it easier to grep for handling/generation of a certain message type
- Refer directly to documentation by following the symbol in IDE
- Move list of valid message types to protocol.cpp:
    protocol.cpp is a more appropriate place for this, and having
    the array there makes it easier to keep things consistent.
@laanwj laanwj force-pushed the laanwj:2015_12_network_messages branch to 9bbe71b Dec 10, 2015
@morcos
Copy link
Member

morcos commented Dec 10, 2015

utACK. Thanks!

@laanwj laanwj merged commit 9bbe71b into bitcoin:master Dec 11, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
laanwj added a commit that referenced this pull request Dec 11, 2015
9bbe71b net: Add and document network messages in protocol.h (Wladimir J. van der Laan)
laanwj added a commit that referenced this pull request Dec 11, 2015
- Avoids string typos (by making the compiler check)
- Makes it easier to grep for handling/generation of a certain message type
- Refer directly to documentation by following the symbol in IDE
- Move list of valid message types to protocol.cpp:
    protocol.cpp is a more appropriate place for this, and having
    the array there makes it easier to keep things consistent.

Github-Pull: #7181
Rebased-From: 9bbe71b
UdjinM6 added a commit to dashpay/dash that referenced this pull request Jun 29, 2017
…itcoin#7181: enable per-command byte counters in `CNode` (#1496)

* log bytes recv/sent per command

* net: Account for `sendheaders` `verack` messages

Looks like these were forgotten in bitcoin#6589.

* Backport remaining part of Bitcoin PR bitcoin#7181.

Most of this PR is already merged, but a small part remaining
that makes per-command byte counts in CNode working.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
spencerlievens added a commit to duality-solutions/Dynamic that referenced this pull request Nov 12, 2017
* enable per-command byte counters in  (#1496)

* log bytes recv/sent per command

* net: Account for   messages

Looks like these were forgotten in #6589.

* Backport remaining part of Bitcoin PR bitcoin/bitcoin#7181.

Most of this PR is already merged, but a small part remaining
that makes per-command byte counts in CNode working.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
AmirolAhmad pushed a commit to AmirolAhmad/gobytes-test that referenced this pull request Dec 11, 2017
… per-command byte counters in `CNode` (#1496)

* log bytes recv/sent per command

* net: Account for `sendheaders` `verack` messages

Looks like these were forgotten in #6589.

* Backport remaining part of Bitcoin PR bitcoin/bitcoin#7181.

Most of this PR is already merged, but a small part remaining
that makes per-command byte counts in CNode working.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
AmirolAhmad pushed a commit to AmirolAhmad/gobytes-test that referenced this pull request Dec 12, 2017
… per-command byte counters in `CNode` (#1496)

* log bytes recv/sent per command

* net: Account for `sendheaders` `verack` messages

Looks like these were forgotten in #6589.

* Backport remaining part of Bitcoin PR bitcoin/bitcoin#7181.

Most of this PR is already merged, but a small part remaining
that makes per-command byte counts in CNode working.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
TriKriSta added a commit to ivansib/sibcoin-16.2 that referenced this pull request Mar 5, 2018
… per-command byte counters in `CNode` (#1496)

* log bytes recv/sent per command

* net: Account for `sendheaders` `verack` messages

Looks like these were forgotten in #6589.

* Backport remaining part of Bitcoin PR bitcoin/bitcoin#7181.

Most of this PR is already merged, but a small part remaining
that makes per-command byte counts in CNode working.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
TriKriSta added a commit to ivansib/sibcoin-16.2 that referenced this pull request Mar 6, 2018
… per-command byte counters in `CNode` (#1496)

* log bytes recv/sent per command

* net: Account for `sendheaders` `verack` messages

Looks like these were forgotten in #6589.

* Backport remaining part of Bitcoin PR bitcoin/bitcoin#7181.

Most of this PR is already merged, but a small part remaining
that makes per-command byte counts in CNode working.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
furszy added a commit to PIVX-Project/PIVX that referenced this pull request May 8, 2020
26b1d9e Apply clang-format (Fuzzbawls)
f12f540 Add and document layer 2 network messages to protocol.h (Fuzzbawls)
7a176ed net: Add and document network messages in protocol.h (Wladimir J. van der Laan)

Pull request description:

  Ported from bitcoin#7181 with layer 2 messages in a followup commit, then ran both commits through `clang-format-diff.py`

  > - Avoids string typos (by making the compiler check)
  > - Makes it easier to grep for handling/generation of a certain message type
  > - Refer directly to documentation by following the symbol in IDE
  > - Move list of valid message types to protocol.cpp:
  >     protocol.cpp is a more appropriate place for this, and having
  >     the array there makes it easier to keep things consistent.

ACKs for top commit:
  random-zebra:
    Very nice. utACK 26b1d9e
  furszy:
    ACK 26b1d9e

Tree-SHA512: a1d08ffb940a66b03856779180e00c212234adc8af3f175e67f694b040e426f35de2cfe6725a3bcdcb606c0468cc33e17e1882a0e2d7f657eebfdb273f0f523c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
You can’t perform that action at this time.