mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01: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:
13
src/net.h
13
src/net.h
@@ -831,7 +831,6 @@ public:
|
||||
|
||||
std::deque<CInv> vRecvGetData;
|
||||
uint64_t nRecvBytes GUARDED_BY(cs_vRecv){0};
|
||||
std::atomic<int> nRecvVersion{INIT_PROTO_VERSION};
|
||||
|
||||
std::atomic<int64_t> nLastSend{0};
|
||||
std::atomic<int64_t> nLastRecv{0};
|
||||
@@ -1018,6 +1017,7 @@ private:
|
||||
const NodeId id;
|
||||
const uint64_t nLocalHostNonce;
|
||||
const ConnectionType m_conn_type;
|
||||
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
|
||||
|
||||
//! Services offered to this peer.
|
||||
//!
|
||||
@@ -1037,7 +1037,6 @@ private:
|
||||
const ServiceFlags nLocalServices;
|
||||
|
||||
const int nMyStartingHeight;
|
||||
int nSendVersion{0};
|
||||
NetPermissionFlags m_permissionFlags{ PF_NONE };
|
||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||
|
||||
@@ -1069,16 +1068,14 @@ public:
|
||||
|
||||
bool ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete);
|
||||
|
||||
void SetRecvVersion(int nVersionIn)
|
||||
void SetCommonVersion(int greatest_common_version)
|
||||
{
|
||||
nRecvVersion = nVersionIn;
|
||||
m_greatest_common_version = greatest_common_version;
|
||||
}
|
||||
int GetRecvVersion() const
|
||||
int GetCommonVersion() const
|
||||
{
|
||||
return nRecvVersion;
|
||||
return m_greatest_common_version;
|
||||
}
|
||||
void SetSendVersion(int nVersionIn);
|
||||
int GetSendVersion() const;
|
||||
|
||||
CService GetAddrLocal() const;
|
||||
//! May not be called more than once
|
||||
|
||||
Reference in New Issue
Block a user