Skip to content

Commit

Permalink
Merge #1467: [Cleanup] Remove redundant and unused code
Browse files Browse the repository at this point in the history
a07dee4 [Cleanup] Remove redundant and unused code (Fuzzbawls)

Pull request description:

  `SPORK_10_MASTERNODE_PAY_UPDATED_NODES` has remained active for the past
  3+ years through multiple protocol updates and was largely already
  deprecated at the time we code-forked from DASH.

  Since the masternode broadcast message was introduced, the only remaining
  practical use of SPORK_10 was a redundant if/else that this PR removes.

  Additionally, since the masternode broadcast message was introduced,
  we no longer need to continue supporting the already deprecated `dsee`
  and `dseep` network messages, which were themselves only ever used when
  SPORK_10 was inactive.

ACKs for top commit:
  random-zebra:
    ACK a07dee4
  furszy:
    utACK a07dee4

Tree-SHA512: 16e5b98a7dcaf747cb5d688aa389e604e5840e4af0bfb92a45ad87037ac108c844fe1360227c4ba87371eb629569bab144849b3bdcbc7b1b970c20460ae22b6d
  • Loading branch information
furszy committed Mar 30, 2020
2 parents 0bbf18e + a07dee4 commit aa50351
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 363 deletions.
70 changes: 0 additions & 70 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,38 +199,6 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage)

mnp.Relay();

/*
* IT'S SAFE TO REMOVE THIS IN FURTHER VERSIONS
* AFTER MIGRATION TO V12 IS DONE
*/

if (sporkManager.IsSporkActive(SPORK_10_MASTERNODE_PAY_UPDATED_NODES)) return true;
// for migration purposes ping our node on old masternodes network too
std::string retErrorMessage;
std::vector<unsigned char> vchMasterNodeSignature;
int64_t masterNodeSignatureTime = GetAdjustedTime();

std::string strMessage = service.ToString() + std::to_string(masterNodeSignatureTime) + std::to_string(false);

if (!CMessageSigner::SignMessage(strMessage, vchMasterNodeSignature, keyMasternode)) {
errorMessage = "dseep sign message failed.";
return false;
}

if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchMasterNodeSignature, strMessage, retErrorMessage)) {
errorMessage = "dseep verify message failed: " + retErrorMessage;
return false;
}

LogPrint("masternode", "dseep - relaying from active mn, %s \n", vin.ToString().c_str());
LOCK(cs_vNodes);
for (CNode* pnode : vNodes)
pnode->PushMessage("dseep", vin, vchMasterNodeSignature, masterNodeSignatureTime, false);

/*
* END OF "REMOVE"
*/

return true;
} else {
// Seems like we are trying to send a ping while the Masternode is not registered in the network
Expand Down Expand Up @@ -307,44 +275,6 @@ bool CActiveMasternode::CreateBroadcast(CTxIn vin, CService service, CKey keyCol
return false;
}

/*
* IT'S SAFE TO REMOVE THIS IN FURTHER VERSIONS
* AFTER MIGRATION TO V12 IS DONE
*/

if (sporkManager.IsSporkActive(SPORK_10_MASTERNODE_PAY_UPDATED_NODES)) return true;
// for migration purposes inject our node in old masternodes' list too
std::string retErrorMessage;
std::vector<unsigned char> vchMasterNodeSignature;
int64_t masterNodeSignatureTime = GetAdjustedTime();
std::string donationAddress = "";
int donationPercantage = 0;

std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end());
std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end());

std::string strMessage = service.ToString() + std::to_string(masterNodeSignatureTime) + vchPubKey + vchPubKey2 + std::to_string(PROTOCOL_VERSION) + donationAddress + std::to_string(donationPercantage);

if (!CMessageSigner::SignMessage(strMessage, vchMasterNodeSignature, keyCollateralAddress)) {
errorMessage = "dsee sign message failed.";
LogPrintf("CActiveMasternode::Register() - Error: %s\n", errorMessage.c_str());
return false;
}

if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchMasterNodeSignature, strMessage, retErrorMessage)) {
errorMessage = "dsee verify message failed: " + retErrorMessage;
LogPrintf("CActiveMasternode::Register() - Error: %s\n", errorMessage.c_str());
return false;
}

LOCK(cs_vNodes);
for (CNode* pnode : vNodes)
pnode->PushMessage("dsee", vin, service, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyCollateralAddress, pubKeyMasternode, -1, -1, masterNodeSignatureTime, PROTOCOL_VERSION, donationAddress, donationPercantage);

/*
* END OF "REMOVE"
*/

return true;
}

Expand Down
5 changes: 1 addition & 4 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe

int CMasternodePayments::GetMinMasternodePaymentsProto()
{
if (sporkManager.IsSporkActive(SPORK_10_MASTERNODE_PAY_UPDATED_NODES))
return ActiveProtocol(); // Allow only updated peers
else
return MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT; // Also allow old peers as long as they are allowed to run
return ActiveProtocol();
}

void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
Expand Down
4 changes: 0 additions & 4 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ CMasternode::CMasternode() :
nScanningErrorCount = 0;
nLastScanningErrorBlockHeight = 0;
lastTimeChecked = 0;
nLastDsee = 0; // temporary, do not save. Remove after migration to v12
nLastDseep = 0; // temporary, do not save. Remove after migration to v12
}

CMasternode::CMasternode(const CMasternode& other) :
Expand All @@ -102,8 +100,6 @@ CMasternode::CMasternode(const CMasternode& other) :
nScanningErrorCount = other.nScanningErrorCount;
nLastScanningErrorBlockHeight = other.nLastScanningErrorBlockHeight;
lastTimeChecked = 0;
nLastDsee = other.nLastDsee; // temporary, do not save. Remove after migration to v12
nLastDseep = other.nLastDseep; // temporary, do not save. Remove after migration to v12
}

uint256 CMasternode::GetSignatureHash() const
Expand Down
3 changes: 0 additions & 3 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ class CMasternode : public CSignedMessage
int nLastScanningErrorBlockHeight;
CMasternodePing lastPing;

int64_t nLastDsee; // temporary, do not save. Remove after migration to v12
int64_t nLastDseep; // temporary, do not save. Remove after migration to v12

CMasternode();
CMasternode(const CMasternode& other);

Expand Down
Loading

0 comments on commit aa50351

Please sign in to comment.