Skip to content

Commit 1836bc7

Browse files
committed
net_processing, fix circ dependency: evo/mnauth -> llmq/quorums_utils -> spork -> net_processing -> evo/mnauth
1 parent 8bf4add commit 1836bc7

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,14 +1923,18 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
19231923
if (std::find(allMessages.begin(), allMessages.end(), strCommand) != allMessages.end()) {
19241924
// Check if the dispatcher can process this message first. If not, try going with the old flow.
19251925
if (!masternodeSync.MessageDispatcher(pfrom, strCommand, vRecv)) {
1926-
// Probably one the extensions
1926+
// Probably one the extensions, future: encapsulate all of this inside tiertwo_networksync.
19271927
int dosScore{0};
19281928
if (!mnodeman.ProcessMessage(pfrom, strCommand, vRecv, dosScore)) {
19291929
WITH_LOCK(cs_main, Misbehaving(pfrom->GetId(), dosScore));
1930+
return false;
19301931
}
19311932
g_budgetman.ProcessMessage(pfrom, strCommand, vRecv);
19321933
masternodePayments.ProcessMessageMasternodePayments(pfrom, strCommand, vRecv);
1933-
sporkManager.ProcessSpork(pfrom, strCommand, vRecv);
1934+
if (!sporkManager.ProcessSpork(pfrom, strCommand, vRecv, dosScore)) {
1935+
WITH_LOCK(cs_main, Misbehaving(pfrom->GetId(), dosScore));
1936+
return false;
1937+
}
19341938
}
19351939
} else {
19361940
// Ignore unknown commands for extensibility

src/spork.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "spork.h"
77

88
#include "netmessagemaker.h"
9-
#include "net_processing.h"
109
#include "sporkdb.h"
1110
#include "validation.h"
1211

@@ -85,20 +84,18 @@ void CSporkManager::LoadSporksFromDB()
8584
}
8685
}
8786

88-
void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
87+
bool CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, int& dosScore)
8988
{
90-
if (fLiteMode) return; // disable all masternode related functionality
89+
if (fLiteMode) return true; // disable all masternode related functionality
9190

9291
if (strCommand == NetMsgType::SPORK) {
93-
int banScore = ProcessSporkMsg(vRecv);
94-
if (banScore > 0) {
95-
LOCK(cs_main);
96-
Misbehaving(pfrom->GetId(), banScore);
97-
}
92+
dosScore = ProcessSporkMsg(vRecv);
93+
return dosScore == 0;
9894
}
9995
if (strCommand == NetMsgType::GETSPORKS) {
10096
ProcessGetSporks(pfrom, strCommand, vRecv);
10197
}
98+
return true;
10299
}
103100

104101
int CSporkManager::ProcessSporkMsg(CDataStream& vRecv)

src/spork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CSporkManager
8484
void Clear();
8585
void LoadSporksFromDB();
8686

87-
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
87+
bool ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, int& dosScore);
8888
int64_t GetSporkValue(SporkId nSporkID);
8989
// Create/Sign/Relay the spork message, and update the maps
9090
bool UpdateSpork(SporkId nSporkID, int64_t nValue);

0 commit comments

Comments
 (0)