mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +02:00
Merge #17785: p2p: Unify Send and Receive protocol versions
ddefb5c0b7p2p: Use the greatest common version in peer logic (Hennadii Stepanov)e084d45562p2p: Remove SetCommonVersion() from VERACK handler (Hennadii Stepanov)8d2026796arefactor: Rename local variable nSendVersion (Hennadii Stepanov)e9a6d8b13bp2p: Unify Send and Receive protocol versions (Hennadii Stepanov) Pull request description: On master (6fef85bfa3) `CNode` has two members to keep protocol version: - `nRecvVersion` for received messages - `nSendVersion` for messages to send After exchanging with `VERSION` and `VERACK` messages via protocol version `INIT_PROTO_VERSION`, both nodes set `nRecvVersion` _and_ `nSendVersion` to _the same_ value which is the greatest common protocol version. This PR: - replaces two `CNode` members, `nRecvVersion` `nSendVersion`, with `m_greatest_common_version` - removes duplicated getter and setter There is no change in behavior on the P2P network. ACKs for top commit: jnewbery: ACKddefb5c0b7naumenkogs: ACKddefb5c0b7fjahr: Code review ACKddefb5c0b7amitiuttarwar: code review but untested ACKddefb5c0b7benthecarman: utACK `ddefb5c` Tree-SHA512: 5305538dbaa5426b923b0afd20bdef4f248d310855d1d78427210c00716c67b7cb691515c421716b6157913e453076e293b10ff5fd2cd26a8e5375d42da7809d
This commit is contained in:
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||
// Mock an outbound peer
|
||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
|
||||
CNode dummyNode1(id++, ServiceFlags(NODE_NETWORK | NODE_WITNESS), 0, INVALID_SOCKET, addr1, 0, 0, CAddress(), "", ConnectionType::OUTBOUND_FULL_RELAY);
|
||||
dummyNode1.SetSendVersion(PROTOCOL_VERSION);
|
||||
dummyNode1.SetCommonVersion(PROTOCOL_VERSION);
|
||||
|
||||
peerLogic->InitializeNode(&dummyNode1);
|
||||
dummyNode1.nVersion = 1;
|
||||
@@ -138,7 +138,7 @@ static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerManager &pee
|
||||
CAddress addr(ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE);
|
||||
vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK | NODE_WITNESS), 0, INVALID_SOCKET, addr, 0, 0, CAddress(), "", ConnectionType::OUTBOUND_FULL_RELAY));
|
||||
CNode &node = *vNodes.back();
|
||||
node.SetSendVersion(PROTOCOL_VERSION);
|
||||
node.SetCommonVersion(PROTOCOL_VERSION);
|
||||
|
||||
peerLogic.InitializeNode(&node);
|
||||
node.nVersion = 1;
|
||||
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
banman->ClearBanned();
|
||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
|
||||
CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 0, 0, CAddress(), "", ConnectionType::INBOUND);
|
||||
dummyNode1.SetSendVersion(PROTOCOL_VERSION);
|
||||
dummyNode1.SetCommonVersion(PROTOCOL_VERSION);
|
||||
peerLogic->InitializeNode(&dummyNode1);
|
||||
dummyNode1.nVersion = 1;
|
||||
dummyNode1.fSuccessfullyConnected = true;
|
||||
@@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
|
||||
CAddress addr2(ip(0xa0b0c002), NODE_NONE);
|
||||
CNode dummyNode2(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr2, 1, 1, CAddress(), "", ConnectionType::INBOUND);
|
||||
dummyNode2.SetSendVersion(PROTOCOL_VERSION);
|
||||
dummyNode2.SetCommonVersion(PROTOCOL_VERSION);
|
||||
peerLogic->InitializeNode(&dummyNode2);
|
||||
dummyNode2.nVersion = 1;
|
||||
dummyNode2.fSuccessfullyConnected = true;
|
||||
@@ -280,7 +280,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
|
||||
CAddress addr(ip(0xa0b0c001), NODE_NONE);
|
||||
CNode dummyNode(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr, 4, 4, CAddress(), "", ConnectionType::INBOUND);
|
||||
dummyNode.SetSendVersion(PROTOCOL_VERSION);
|
||||
dummyNode.SetCommonVersion(PROTOCOL_VERSION);
|
||||
peerLogic->InitializeNode(&dummyNode);
|
||||
dummyNode.nVersion = 1;
|
||||
dummyNode.fSuccessfullyConnected = true;
|
||||
|
||||
Reference in New Issue
Block a user