mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Dont skip sendmessages (#3534)
* Revert "Only call SendMessages when ProcessMessages did some work or when some time passed"
This reverts commit 24ead62905
.
* Only skip SendMessages() for fMasternode connections
This commit is contained in:
parent
3f8a7b2068
commit
c1f889c564
18
src/net.cpp
18
src/net.cpp
@ -2708,19 +2708,18 @@ void CConnman::OpenMasternodeConnection(const CAddress &addrConnect, bool probe)
|
||||
|
||||
void CConnman::ThreadMessageHandler()
|
||||
{
|
||||
int64_t nLastForceSendMessages = 0;
|
||||
int64_t nLastSendMessagesTimeMasternodes = 0;
|
||||
|
||||
while (!flagInterruptMsgProc)
|
||||
{
|
||||
std::vector<CNode*> vNodesCopy = CopyNodeVector();
|
||||
|
||||
int64_t nNow = GetTimeMillis();
|
||||
|
||||
bool fMoreWork = false;
|
||||
bool fForceSendMessages = false;
|
||||
if (nNow - nLastForceSendMessages >= 100) {
|
||||
fForceSendMessages = true;
|
||||
nLastForceSendMessages = nNow;
|
||||
|
||||
bool fSkipSendMessagesForMasternodes = true;
|
||||
if (GetTimeMillis() - nLastSendMessagesTimeMasternodes >= 100) {
|
||||
fSkipSendMessagesForMasternodes = false;
|
||||
nLastSendMessagesTimeMasternodes = GetTimeMillis();
|
||||
}
|
||||
|
||||
for (CNode* pnode : vNodesCopy)
|
||||
@ -2729,13 +2728,12 @@ void CConnman::ThreadMessageHandler()
|
||||
continue;
|
||||
|
||||
// Receive messages
|
||||
bool fDidWork = false;
|
||||
bool fMoreNodeWork = m_msgproc->ProcessMessages(pnode, flagInterruptMsgProc, fDidWork);
|
||||
bool fMoreNodeWork = m_msgproc->ProcessMessages(pnode, flagInterruptMsgProc);
|
||||
fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend);
|
||||
if (flagInterruptMsgProc)
|
||||
return;
|
||||
// Send messages
|
||||
if (fDidWork || fForceSendMessages) {
|
||||
if (!fSkipSendMessagesForMasternodes || !pnode->fMasternode) {
|
||||
LOCK(pnode->cs_sendProcessing);
|
||||
m_msgproc->SendMessages(pnode, flagInterruptMsgProc);
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ struct CombinerAll
|
||||
class NetEventsInterface
|
||||
{
|
||||
public:
|
||||
virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt, bool &fRetDidWork) = 0;
|
||||
virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
|
||||
virtual bool SendMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
|
||||
virtual void InitializeNode(CNode* pnode) = 0;
|
||||
virtual void FinalizeNode(NodeId id, bool& update_connection_time) = 0;
|
||||
|
@ -3597,7 +3597,7 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman, bool en
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc, bool &fRetDidWork)
|
||||
bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
//
|
||||
@ -3609,17 +3609,13 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||
// (x) data
|
||||
//
|
||||
bool fMoreWork = false;
|
||||
fRetDidWork = false;
|
||||
|
||||
if (!pfrom->vRecvGetData.empty()) {
|
||||
if (!pfrom->vRecvGetData.empty())
|
||||
ProcessGetData(pfrom, chainparams, connman, interruptMsgProc);
|
||||
fRetDidWork = true;
|
||||
}
|
||||
|
||||
if (!pfrom->orphan_work_set.empty()) {
|
||||
LOCK2(cs_main, g_cs_orphans);
|
||||
ProcessOrphanTx(connman, pfrom->orphan_work_set);
|
||||
fRetDidWork = true;
|
||||
}
|
||||
|
||||
if (pfrom->fDisconnect)
|
||||
@ -3643,7 +3639,6 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||
pfrom->nProcessQueueSize -= msgs.front().vRecv.size() + CMessageHeader::HEADER_SIZE;
|
||||
pfrom->fPauseRecv = pfrom->nProcessQueueSize > connman->GetReceiveFloodSize();
|
||||
fMoreWork = !pfrom->vProcessMsg.empty();
|
||||
fRetDidWork = true;
|
||||
}
|
||||
CNetMessage& msg(msgs.front());
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
/** Handle removal of a peer by updating various state and removing it from mapNodeState */
|
||||
void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
|
||||
/** Process protocol messages received from a given node */
|
||||
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt, bool &fRetDidWork) override;
|
||||
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
|
||||
/**
|
||||
* Send queued protocol messages to be sent to a give node.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user