|
|
@@ -89,10 +89,6 @@ std::string strSubVersion; |
|
|
|
|
|
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
|
|
|
|
|
|
-// Signals for message handling
|
|
|
-static CNodeSignals g_signals;
|
|
|
-CNodeSignals& GetNodeSignals() { return g_signals; }
|
|
|
-
|
|
|
void CConnman::AddOneShot(const std::string& strDest)
|
|
|
{
|
|
|
LOCK(cs_vOneShots);
|
|
|
@@ -1114,7 +1110,9 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) { |
|
|
CNode* pnode = new CNode(id, nLocalServices, GetBestHeight(), hSocket, addr, CalculateKeyedNetGroup(addr), nonce, addr_bind, "", true);
|
|
|
pnode->AddRef();
|
|
|
pnode->fWhitelisted = whitelisted;
|
|
|
- GetNodeSignals().InitializeNode(pnode, *this);
|
|
|
+ if (messageInterface) {
|
|
|
+ messageInterface->InitializeNode(pnode);
|
|
|
+ }
|
|
|
|
|
|
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString());
|
|
|
|
|
|
@@ -1966,7 +1964,9 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai |
|
|
if (fAddnode)
|
|
|
pnode->fAddnode = true;
|
|
|
|
|
|
- GetNodeSignals().InitializeNode(pnode, *this);
|
|
|
+ if (messageInterface) {
|
|
|
+ messageInterface->InitializeNode(pnode);
|
|
|
+ }
|
|
|
{
|
|
|
LOCK(cs_vNodes);
|
|
|
vNodes.push_back(pnode);
|
|
|
@@ -1995,16 +1995,17 @@ void CConnman::ThreadMessageHandler() |
|
|
if (pnode->fDisconnect)
|
|
|
continue;
|
|
|
|
|
|
- // Receive messages
|
|
|
- bool fMoreNodeWork = GetNodeSignals().ProcessMessages(pnode, *this, flagInterruptMsgProc);
|
|
|
- fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend);
|
|
|
- if (flagInterruptMsgProc)
|
|
|
- return;
|
|
|
-
|
|
|
- // Send messages
|
|
|
- {
|
|
|
- LOCK(pnode->cs_sendProcessing);
|
|
|
- GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
|
|
|
+ if (messageInterface) {
|
|
|
+ // Receive messages
|
|
|
+ bool fMoreNodeWork = messageInterface->ProcessMessages(pnode, flagInterruptMsgProc);
|
|
|
+ fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend);
|
|
|
+ if (flagInterruptMsgProc)
|
|
|
+ return;
|
|
|
+ // Send messages
|
|
|
+ {
|
|
|
+ LOCK(pnode->cs_sendProcessing);
|
|
|
+ messageInterface->SendMessages(pnode, flagInterruptMsgProc);
|
|
|
+ }
|
|
|
}
|
|
|
if (flagInterruptMsgProc)
|
|
|
return;
|
|
|
@@ -2212,6 +2213,7 @@ CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSe |
|
|
nMaxAddnode = 0;
|
|
|
nBestHeight = 0;
|
|
|
clientInterface = NULL;
|
|
|
+ messageInterface = NULL;
|
|
|
flagInterruptMsgProc = false;
|
|
|
}
|
|
|
|
|
|
@@ -2274,6 +2276,7 @@ bool CConnman::Start(CScheduler& scheduler, Options connOptions) |
|
|
SetBestHeight(connOptions.nBestHeight);
|
|
|
|
|
|
clientInterface = connOptions.uiInterface;
|
|
|
+ messageInterface = connOptions.messageInterface;
|
|
|
|
|
|
if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds)) {
|
|
|
if (clientInterface) {
|
|
|
@@ -2459,9 +2462,12 @@ void CConnman::DeleteNode(CNode* pnode) |
|
|
{
|
|
|
assert(pnode);
|
|
|
bool fUpdateConnectionTime = false;
|
|
|
- GetNodeSignals().FinalizeNode(pnode->GetId(), fUpdateConnectionTime);
|
|
|
- if(fUpdateConnectionTime)
|
|
|
- addrman.Connected(pnode->addr);
|
|
|
+ if (messageInterface) {
|
|
|
+ messageInterface->FinalizeNode(pnode->GetId(), fUpdateConnectionTime);
|
|
|
+ if(fUpdateConnectionTime) {
|
|
|
+ addrman.Connected(pnode->addr);
|
|
|
+ }
|
|
|
+ }
|
|
|
delete pnode;
|
|
|
}
|
|
|
|
|
|
|