mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-13 00:28:03 +00:00
remove "checkorder" and "reply" P2P commands
These command are a leftover from send-to-IP transactions, which have been removed a long time ago. Also removes CNode::mapRequests and CNode::PushRequests, as these were only used for the mentioned commands.
This commit is contained in:
parent
0547b02af7
commit
529a4d4824
48
src/main.cpp
48
src/main.cpp
@ -2413,7 +2413,6 @@ unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };
|
|||||||
|
|
||||||
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
static map<CService, CPubKey> mapReuseKey;
|
|
||||||
RandAddSeedPerfmon();
|
RandAddSeedPerfmon();
|
||||||
if (fDebug)
|
if (fDebug)
|
||||||
printf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size());
|
printf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size());
|
||||||
@ -2921,53 +2920,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, (int)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, (int)0, scriptPubKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
else if (strCommand == "reply")
|
|
||||||
{
|
|
||||||
uint256 hashReply;
|
|
||||||
vRecv >> hashReply;
|
|
||||||
|
|
||||||
CRequestTracker tracker;
|
|
||||||
{
|
|
||||||
LOCK(pfrom->cs_mapRequests);
|
|
||||||
map<uint256, CRequestTracker>::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")
|
else if (strCommand == "ping")
|
||||||
{
|
{
|
||||||
if (pfrom->nVersion > BIP0031_VERSION)
|
if (pfrom->nVersion > BIP0031_VERSION)
|
||||||
|
@ -20,7 +20,6 @@ class CReserveKey;
|
|||||||
|
|
||||||
class CAddress;
|
class CAddress;
|
||||||
class CInv;
|
class CInv;
|
||||||
class CRequestTracker;
|
|
||||||
class CNode;
|
class CNode;
|
||||||
|
|
||||||
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
||||||
|
@ -710,9 +710,6 @@ void ThreadSocketHandler2(void* parg)
|
|||||||
{
|
{
|
||||||
TRY_LOCK(pnode->cs_vRecv, lockRecv);
|
TRY_LOCK(pnode->cs_vRecv, lockRecv);
|
||||||
if (lockRecv)
|
if (lockRecv)
|
||||||
{
|
|
||||||
TRY_LOCK(pnode->cs_mapRequests, lockReq);
|
|
||||||
if (lockReq)
|
|
||||||
{
|
{
|
||||||
TRY_LOCK(pnode->cs_inventory, lockInv);
|
TRY_LOCK(pnode->cs_inventory, lockInv);
|
||||||
if (lockInv)
|
if (lockInv)
|
||||||
@ -720,7 +717,6 @@ void ThreadSocketHandler2(void* parg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (fDelete)
|
if (fDelete)
|
||||||
{
|
{
|
||||||
vNodesDisconnected.remove(pnode);
|
vNodesDisconnected.remove(pnode);
|
||||||
|
69
src/net.h
69
src/net.h
@ -19,7 +19,6 @@
|
|||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "addrman.h"
|
#include "addrman.h"
|
||||||
|
|
||||||
class CRequestTracker;
|
|
||||||
class CNode;
|
class CNode;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
extern int nBestHeight;
|
extern int nBestHeight;
|
||||||
@ -74,25 +73,6 @@ enum
|
|||||||
MSG_BLOCK,
|
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 */
|
/** Thread types */
|
||||||
enum threadId
|
enum threadId
|
||||||
{
|
{
|
||||||
@ -188,8 +168,6 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int64 nReleaseTime;
|
int64 nReleaseTime;
|
||||||
std::map<uint256, CRequestTracker> mapRequests;
|
|
||||||
CCriticalSection cs_mapRequests;
|
|
||||||
uint256 hashContinue;
|
uint256 hashContinue;
|
||||||
CBlockIndex* pindexLastGetBlocksBegin;
|
CBlockIndex* pindexLastGetBlocksBegin;
|
||||||
uint256 hashLastGetBlocksEnd;
|
uint256 hashLastGetBlocksEnd;
|
||||||
@ -563,53 +541,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PushRequest(const char* pszCommand,
|
|
||||||
void (*fn)(void*, CDataStream&), void* param1)
|
|
||||||
{
|
|
||||||
uint256 hashReply;
|
|
||||||
RAND_bytes((unsigned char*)&hashReply, sizeof(hashReply));
|
|
||||||
|
|
||||||
{
|
|
||||||
LOCK(cs_mapRequests);
|
|
||||||
mapRequests[hashReply] = CRequestTracker(fn, param1);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushMessage(pszCommand, hashReply);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T1>
|
|
||||||
void PushRequest(const char* pszCommand, const T1& a1,
|
|
||||||
void (*fn)(void*, CDataStream&), void* param1)
|
|
||||||
{
|
|
||||||
uint256 hashReply;
|
|
||||||
RAND_bytes((unsigned char*)&hashReply, sizeof(hashReply));
|
|
||||||
|
|
||||||
{
|
|
||||||
LOCK(cs_mapRequests);
|
|
||||||
mapRequests[hashReply] = CRequestTracker(fn, param1);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushMessage(pszCommand, hashReply, a1);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
|
||||||
void PushRequest(const char* pszCommand, const T1& a1, const T2& a2,
|
|
||||||
void (*fn)(void*, CDataStream&), void* param1)
|
|
||||||
{
|
|
||||||
uint256 hashReply;
|
|
||||||
RAND_bytes((unsigned char*)&hashReply, sizeof(hashReply));
|
|
||||||
|
|
||||||
{
|
|
||||||
LOCK(cs_mapRequests);
|
|
||||||
mapRequests[hashReply] = CRequestTracker(fn, param1);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushMessage(pszCommand, hashReply, a1, a2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd);
|
void PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd);
|
||||||
bool IsSubscribed(unsigned int nChannel);
|
bool IsSubscribed(unsigned int nChannel);
|
||||||
void Subscribe(unsigned int nChannel, unsigned int nHops=0);
|
void Subscribe(unsigned int nChannel, unsigned int nHops=0);
|
||||||
|
Loading…
Reference in New Issue
Block a user