From e5b49385b8b449b0eeead6586c6fedb4ff4bd59d Mon Sep 17 00:00:00 2001 From: svost Date: Thu, 17 Feb 2022 23:34:30 +0300 Subject: [PATCH] Code cleanup --- src/main.cpp | 48 ------------------------------------------------ src/main.h | 1 - src/net.cpp | 10 +++------- src/net.h | 21 --------------------- 4 files changed, 3 insertions(+), 77 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 682eae7..79f8e92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3114,7 +3114,6 @@ unsigned char pchMessageStart[4] = { 0xe4, 0xe8, 0xe9, 0xe5 }; bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { - static map mapReuseKey; RandAddSeedPerfmon(); if (fDebug) printf("received: %s (%" PRIszu " bytes)\n", strCommand.c_str(), vRecv.size()); @@ -3664,53 +3663,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } - else if (strCommand == "checkorder") - { - uint256 hashReply; - vRecv >> hashReply; - - if (!GetBoolArg("-allowreceivebyip")) - { - pfrom->PushMessage("reply", hashReply, 2, string("")); - return true; - } - - CWalletTx order; - vRecv >> order; - - /// we have a chance to check the order here - - // Keep giving the same key to the same ip until they use it - if (!mapReuseKey.count(pfrom->addr)) - pwalletMain->GetKeyFromPool(mapReuseKey[pfrom->addr], true); - - // Send back approval of order and pubkey to use - CScript scriptPubKey; - scriptPubKey << mapReuseKey[pfrom->addr] << OP_CHECKSIG; - pfrom->PushMessage("reply", hashReply, 0, scriptPubKey); - } - - - else if (strCommand == "reply") - { - uint256 hashReply; - vRecv >> hashReply; - - CRequestTracker tracker; - { - LOCK(pfrom->cs_mapRequests); - map::iterator mi = pfrom->mapRequests.find(hashReply); - if (mi != pfrom->mapRequests.end()) - { - tracker = (*mi).second; - pfrom->mapRequests.erase(mi); - } - } - if (!tracker.IsNull()) - tracker.fn(tracker.param1, vRecv); - } - - else if (strCommand == "ping") { uint64_t nonce = 0; diff --git a/src/main.h b/src/main.h index b3bff19..205110e 100644 --- a/src/main.h +++ b/src/main.h @@ -25,7 +25,6 @@ class COutPoint; class CAddress; class CInv; -class CRequestTracker; class CNode; // diff --git a/src/net.cpp b/src/net.cpp index f5ef026..93cbf41 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -734,13 +734,9 @@ void ThreadSocketHandler2(void* parg) TRY_LOCK(pnode->cs_vRecv, lockRecv); if (lockRecv) { - TRY_LOCK(pnode->cs_mapRequests, lockReq); - if (lockReq) - { - TRY_LOCK(pnode->cs_inventory, lockInv); - if (lockInv) - fDelete = true; - } + TRY_LOCK(pnode->cs_inventory, lockInv); + if (lockInv) + fDelete = true; } } } diff --git a/src/net.h b/src/net.h index 8600bed..fed6b4d 100644 --- a/src/net.h +++ b/src/net.h @@ -19,7 +19,6 @@ #include -class CRequestTracker; class CNode; class CBlockIndex; extern int nBestHeight; @@ -79,24 +78,6 @@ enum MSG_BLOCK }; -class CRequestTracker -{ -public: - void (*fn)(void*, CDataStream&); - void* param1; - - explicit CRequestTracker(void (*fnIn)(void*, CDataStream&)=NULL, void* param1In=NULL) - { - fn = fnIn; - param1 = param1In; - } - - bool IsNull() - { - return fn == NULL; - } -}; - /** Thread types */ enum threadId @@ -205,8 +186,6 @@ protected: public: int64_t nReleaseTime; - std::map mapRequests; - CCriticalSection cs_mapRequests; uint256 hashContinue; CBlockIndex* pindexLastGetBlocksBegin; uint256 hashLastGetBlocksEnd; -- 1.7.1