Skip to content

Commit 5b15254

Browse files
committed
Prepare to drop legacy "acid" field from block and ping messages
This removes the GetCommandNonce() and SecurityTest() functions and props up the net messaging that used these legacy fields to prepare for final removal in the release following the mandatory version.
1 parent 9605099 commit 5b15254

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

src/main.cpp

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ extern bool WalletOutOfSync();
3939
extern bool AskForOutstandingBlocks(uint256 hashStart);
4040
extern void ResetTimerMain(std::string timer_name);
4141
extern bool GridcoinServices();
42-
std::string GetCommandNonce(std::string command);
4342

4443
unsigned int nNodeLifespan;
4544

@@ -4383,12 +4382,6 @@ std::string NodeAddress(CNode* pfrom)
43834382
return ip;
43844383
}
43854384

4386-
bool SecurityTest(CNode* pfrom, bool acid_test)
4387-
{
4388-
if (pfrom->nStartingHeight > (nBestHeight*.5) && acid_test) return true;
4389-
return false;
4390-
}
4391-
43924385
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
43934386
{
43944387
RandAddSeedPerfmon();
@@ -4545,12 +4538,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
45454538
{
45464539
if (((CNetAddr)pfrom->addr) == (CNetAddr)addrFrom)
45474540
{
4548-
if (SecurityTest(pfrom,true))
4549-
{
4550-
//Dont store the peer unless it passes the test
4551-
addrman.Add(addrFrom, addrFrom);
4552-
addrman.Good(addrFrom);
4553-
}
4541+
addrman.Add(addrFrom, addrFrom);
4542+
addrman.Good(addrFrom);
45544543
}
45554544
}
45564545

@@ -4758,9 +4747,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
47584747
{
47594748
CBlock block;
47604749
block.ReadFromDisk((*mi).second);
4761-
//HALFORD 12-26-2014
4762-
std::string acid = GetCommandNonce("encrypt");
4763-
pfrom->PushMessage("encrypt", block, acid);
4750+
4751+
// TODO: drop legacy "command nonce" removal transition in the next
4752+
// release after the mandatory version:
4753+
//
4754+
if (pfrom->nVersion >= PROTOCOL_VERSION) {
4755+
pfrom->PushMessage("encrypt", block);
4756+
} else {
4757+
std::string acid;
4758+
pfrom->PushMessage("encrypt", block, acid);
4759+
}
47644760

47654761
// Trigger them to send a getblocks request for the next batch of inventory
47664762
if (inv.hash == pfrom->hashContinue)
@@ -4984,8 +4980,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49844980
//Response from getblocks, message = block
49854981

49864982
CBlock block;
4987-
std::string acid = "";
4988-
vRecv >> block >> acid;
4983+
vRecv >> block;
4984+
4985+
// TODO: drop legacy "command nonce" removal transition in the next
4986+
// release after the mandatory version:
4987+
//
4988+
if (pfrom->nVersion < PROTOCOL_VERSION) {
4989+
std::string acid;
4990+
vRecv >> acid;
4991+
}
4992+
49894993
uint256 hashBlock = block.GetHash(true);
49904994

49914995
LogPrintf(" Received block %s; ", hashBlock.ToString());
@@ -5059,10 +5063,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
50595063
}
50605064
else if (strCommand == "ping")
50615065
{
5062-
std::string acid = "";
50635066
uint64_t nonce = 0;
5067+
vRecv >> nonce;
50645068

5065-
vRecv >> nonce >> acid;
5069+
// TODO: drop legacy "command nonce" removal transition in the next
5070+
// release after the mandatory version:
5071+
//
5072+
if (pfrom->nVersion < PROTOCOL_VERSION) {
5073+
std::string acid;
5074+
vRecv >> acid;
5075+
}
50665076

50675077
// Echo the message back with the nonce. This allows for two useful features:
50685078
//
@@ -5356,8 +5366,15 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
53565366
pto->nPingUsecStart = GetTimeMicros();
53575367
pto->nPingNonceSent = nonce;
53585368

5359-
std::string acid = GetCommandNonce("ping");
5360-
pto->PushMessage("ping", nonce, acid);
5369+
// TODO: drop legacy "command nonce" removal transition in the next
5370+
// release after the mandatory version:
5371+
//
5372+
if (pto->nVersion >= PROTOCOL_VERSION) {
5373+
pto->PushMessage("ping", nonce);
5374+
} else {
5375+
std::string acid;
5376+
pto->PushMessage("ping", nonce, acid);
5377+
}
53615378
}
53625379

53635380
// Resend wallet transactions that haven't gotten in a block yet

src/net.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
using namespace std;
3737
std::string NodeAddress(CNode* pfrom);
38-
extern std::string GetCommandNonce(std::string command);
3938

4039
extern int nMaxConnections;
4140
int MAX_OUTBOUND_CONNECTIONS = 8;
@@ -114,14 +113,6 @@ unsigned short GetListenPort()
114113
return (unsigned short)(GetArg("-port", GetDefaultPort()));
115114
}
116115

117-
118-
std::string GetCommandNonce(std::string command)
119-
{
120-
return "deprecated,d,d,d,d,d,d";
121-
}
122-
123-
124-
125116
void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd, bool fForce)
126117
{
127118
// The line of code below is the line of code that kept us from syncing to the best block (fForce forces the sync to continue).

0 commit comments

Comments
 (0)