@@ -1259,7 +1259,7 @@ std::chrono::microseconds GetObjectRandomDelay(int invType)
12591259 return {};
12601260}
12611261
1262- std::chrono::microseconds CalculateObjectGetDataTime (const CInv& inv, std::chrono::microseconds current_time, bool use_inbound_delay) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1262+ std::chrono::microseconds CalculateObjectGetDataTime (const CInv& inv, std::chrono::microseconds current_time, bool is_masternode, bool use_inbound_delay) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
12631263{
12641264 AssertLockHeld (cs_main);
12651265 std::chrono::microseconds process_time;
@@ -1274,12 +1274,12 @@ std::chrono::microseconds CalculateObjectGetDataTime(const CInv& inv, std::chron
12741274 }
12751275
12761276 // We delay processing announcements from inbound peers
1277- if (inv.IsMsgTx () && !fMasternodeMode && use_inbound_delay) process_time += INBOUND_PEER_TX_DELAY;
1277+ if (inv.IsMsgTx () && !is_masternode && use_inbound_delay) process_time += INBOUND_PEER_TX_DELAY;
12781278
12791279 return process_time;
12801280}
12811281
1282- void RequestObject (CNodeState* state, const CInv& inv, std::chrono::microseconds current_time, bool fForce = false ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1282+ void RequestObject (CNodeState* state, const CInv& inv, std::chrono::microseconds current_time, bool is_masternode, bool fForce = false ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
12831283{
12841284 AssertLockHeld (cs_main);
12851285 CNodeState::ObjectDownloadState& peer_download_state = state->m_object_download ;
@@ -1294,7 +1294,7 @@ void RequestObject(CNodeState* state, const CInv& inv, std::chrono::microseconds
12941294
12951295 // Calculate the time to try requesting this transaction. Use
12961296 // fPreferredDownload as a proxy for outbound peers.
1297- std::chrono::microseconds process_time = CalculateObjectGetDataTime (inv, current_time, !state->fPreferredDownload );
1297+ std::chrono::microseconds process_time = CalculateObjectGetDataTime (inv, current_time, is_masternode, !state->fPreferredDownload );
12981298
12991299 peer_download_state.m_object_process_time .emplace (process_time, inv);
13001300
@@ -1307,14 +1307,14 @@ void RequestObject(CNodeState* state, const CInv& inv, std::chrono::microseconds
13071307 LogPrint (BCLog::NET, " %s -- inv=(%s), current_time=%d, process_time=%d, delta=%d\n " , __func__, inv.ToString (), current_time.count (), process_time.count (), (process_time - current_time).count ());
13081308}
13091309
1310- void RequestObject (NodeId nodeId, const CInv& inv, std::chrono::microseconds current_time, bool fForce ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1310+ void RequestObject (NodeId nodeId, const CInv& inv, std::chrono::microseconds current_time, bool is_masternode, bool fForce ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
13111311{
13121312 AssertLockHeld (cs_main);
13131313 auto * state = State (nodeId);
13141314 if (!state) {
13151315 return ;
13161316 }
1317- RequestObject (state, inv, current_time, fForce );
1317+ RequestObject (state, inv, current_time, is_masternode, fForce );
13181318}
13191319
13201320size_t GetRequestedObjectCount (NodeId nodeId)
@@ -3127,6 +3127,7 @@ void PeerManagerImpl::ProcessMessage(
31273127 LogPrint (BCLog::NET, " received: %s (%u bytes) peer=%d\n " , SanitizeString (msg_type), vRecv.size (), pfrom.GetId ());
31283128 statsClient.inc (" message.received." + SanitizeString (msg_type), 1 .0f );
31293129
3130+ const bool is_masternode = m_mn_activeman != nullptr ;
31303131
31313132 PeerRef peer = GetPeerRef (pfrom.GetId ());
31323133 if (peer == nullptr ) return ;
@@ -3197,7 +3198,7 @@ void PeerManagerImpl::ProcessMessage(
31973198 pfrom.m_masternode_connection = fOtherMasternode ;
31983199 if (fOtherMasternode ) {
31993200 LogPrint (BCLog::NET_NETCONN, " peer=%d is an inbound masternode connection, not relaying anything to it\n " , pfrom.GetId ());
3200- if (!fMasternodeMode ) {
3201+ if (!is_masternode ) {
32013202 LogPrint (BCLog::NET_NETCONN, " but we're not a masternode, disconnecting\n " );
32023203 pfrom.fDisconnect = true ;
32033204 return ;
@@ -3374,8 +3375,8 @@ void PeerManagerImpl::ProcessMessage(
33743375 pfrom.ConnectionTypeAsString ());
33753376 }
33763377
3377- if (fMasternodeMode && !pfrom.m_masternode_probe_connection ) {
3378- CMNAuth::PushMNAUTH (pfrom, m_connman, *Assert ( m_mn_activeman) , m_chainman.ActiveChain ().Tip ());
3378+ if (is_masternode && !pfrom.m_masternode_probe_connection ) {
3379+ CMNAuth::PushMNAUTH (pfrom, m_connman, *m_mn_activeman, m_chainman.ActiveChain ().Tip ());
33793380 }
33803381
33813382 // Tell our peer we prefer to receive headers rather than inv's
@@ -3674,7 +3675,7 @@ void PeerManagerImpl::ProcessMessage(
36743675 }
36753676 bool allowWhileInIBD = allowWhileInIBDObjs.count (inv.type );
36763677 if (allowWhileInIBD || !m_chainman.ActiveChainstate ().IsInitialBlockDownload ()) {
3677- RequestObject (State (pfrom.GetId ()), inv, current_time);
3678+ RequestObject (State (pfrom.GetId ()), inv, current_time, is_masternode );
36783679 }
36793680 }
36803681 }
@@ -4026,11 +4027,11 @@ void PeerManagerImpl::ProcessMessage(
40264027 for (const uint256& parent_txid : unique_parents) {
40274028 CInv _inv (MSG_TX, parent_txid);
40284029 pfrom.AddKnownInventory (_inv.hash );
4029- if (!AlreadyHave (_inv)) RequestObject (State (pfrom.GetId ()), _inv, current_time);
4030+ if (!AlreadyHave (_inv)) RequestObject (State (pfrom.GetId ()), _inv, current_time, is_masternode );
40304031 // We don't know if the previous tx was a regular or a mixing one, try both
40314032 CInv _inv2 (MSG_DSTX, parent_txid);
40324033 pfrom.AddKnownInventory (_inv2.hash );
4033- if (!AlreadyHave (_inv2)) RequestObject (State (pfrom.GetId ()), _inv2, current_time);
4034+ if (!AlreadyHave (_inv2)) RequestObject (State (pfrom.GetId ()), _inv2, current_time, is_masternode );
40344035 }
40354036 AddOrphanTx (ptx, pfrom.GetId ());
40364037
@@ -4743,7 +4744,7 @@ void PeerManagerImpl::ProcessMessage(
47434744 ProcessPeerMsgRet (m_govman.ProcessMessage (pfrom, m_connman, *this , msg_type, vRecv), pfrom);
47444745 ProcessPeerMsgRet (CMNAuth::ProcessMessage (pfrom, m_connman, m_mn_metaman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip (), msg_type, vRecv), pfrom);
47454746 ProcessPeerMsgRet (m_llmq_ctx->quorum_block_processor ->ProcessMessage (pfrom, msg_type, vRecv), pfrom);
4746- ProcessPeerMsgRet (m_llmq_ctx->qdkgsman ->ProcessMessage (pfrom, this , /* is_masternode = */ m_mn_activeman != nullptr , msg_type, vRecv), pfrom);
4747+ ProcessPeerMsgRet (m_llmq_ctx->qdkgsman ->ProcessMessage (pfrom, this , is_masternode, msg_type, vRecv), pfrom);
47474748 ProcessPeerMsgRet (m_llmq_ctx->qman ->ProcessMessage (pfrom, msg_type, vRecv), pfrom);
47484749 m_llmq_ctx->shareman ->ProcessMessage (pfrom, m_sporkman, msg_type, vRecv);
47494750 ProcessPeerMsgRet (m_llmq_ctx->sigman ->ProcessMessage (pfrom, this , msg_type, vRecv), pfrom);
@@ -5203,6 +5204,8 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
52035204{
52045205 assert (m_llmq_ctx);
52055206
5207+ const bool is_masternode = m_mn_activeman != nullptr ;
5208+
52065209 PeerRef peer = GetPeerRef (pto->GetId ());
52075210 if (!peer) return false ;
52085211 const Consensus::Params& consensusParams = m_chainparams.GetConsensus ();
@@ -5463,7 +5466,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
54635466 // Check whether periodic sends should happen
54645467 // Note: If this node is running in a Masternode mode, it makes no sense to delay outgoing txes
54655468 // because we never produce any txes ourselves i.e. no privacy is lost in this case.
5466- bool fSendTrickle = pto->HasPermission (NetPermissionFlags::NoBan) || fMasternodeMode ;
5469+ bool fSendTrickle = pto->HasPermission (NetPermissionFlags::NoBan) || is_masternode ;
54675470 if (pto->m_tx_relay ->nNextInvSend < current_time) {
54685471 fSendTrickle = true ;
54695472 if (pto->IsInboundConn ()) {
@@ -5731,7 +5734,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
57315734 // up processing to happen after the download times out
57325735 // (with a slight delay for inbound peers, to prefer
57335736 // requests to outbound peers).
5734- const auto next_process_time = CalculateObjectGetDataTime (inv, current_time, !state.fPreferredDownload );
5737+ const auto next_process_time = CalculateObjectGetDataTime (inv, current_time, is_masternode, !state.fPreferredDownload );
57355738 object_process_time.emplace (next_process_time, inv);
57365739 LogPrint (BCLog::NET, " %s -- GETDATA re-queue inv=(%s), next_process_time=%d, delta=%d, peer=%d\n " , __func__, inv.ToString (), next_process_time.count (), (next_process_time - current_time).count (), pto->GetId ());
57375740 }
0 commit comments