diff --git a/src/masternode.h b/src/masternode.h index 3d242a775d2fb..29636901ba62c 100644 --- a/src/masternode.h +++ b/src/masternode.h @@ -71,25 +71,7 @@ class CMasternodePing : public CSignedMessage bool CheckAndUpdate(int& nDos, bool fRequireAvailable = true, bool fCheckSigTimeOnly = false); void Relay(); - void swap(CMasternodePing& first, CMasternodePing& second) // nothrow - { - CSignedMessage::swap(first, second); - - // enable ADL (not necessary in our case, but good practice) - using std::swap; - - // by swapping the members of two classes, - // the two classes are effectively swapped - swap(first.vin, second.vin); - swap(first.blockHash, second.blockHash); - swap(first.sigTime, second.sigTime); - } - - CMasternodePing& operator=(CMasternodePing from) - { - swap(*this, from); - return *this; - } + CMasternodePing& operator=(const CMasternodePing& other) = default; friend bool operator==(const CMasternodePing& a, const CMasternodePing& b) { @@ -142,31 +124,22 @@ class CMasternode : public CSignedMessage void SetLastPing(const CMasternodePing& _lastPing) { WITH_LOCK(cs, lastPing = _lastPing;); } - void swap(CMasternode& first, CMasternode& second) // nothrow - { - CSignedMessage::swap(first, second); - - // enable ADL (not necessary in our case, but good practice) - using std::swap; - - // by swapping the members of two classes, - // the two classes are effectively swapped - swap(first.vin, second.vin); - swap(first.addr, second.addr); - swap(first.pubKeyCollateralAddress, second.pubKeyCollateralAddress); - swap(first.pubKeyMasternode, second.pubKeyMasternode); - swap(first.sigTime, second.sigTime); - swap(first.lastPing, second.lastPing); - swap(first.protocolVersion, second.protocolVersion); - swap(first.nScanningErrorCount, second.nScanningErrorCount); - swap(first.nLastScanningErrorBlockHeight, second.nLastScanningErrorBlockHeight); - } - - CMasternode& operator=(CMasternode from) + CMasternode& operator=(const CMasternode& other) { - swap(*this, from); + nMessVersion = other.nMessVersion; + vchSig = other.vchSig; + vin = other.vin; + addr = other.addr; + pubKeyCollateralAddress = other.pubKeyCollateralAddress; + pubKeyMasternode = other.pubKeyMasternode; + sigTime = other.sigTime; + lastPing = other.lastPing; + protocolVersion = other.protocolVersion; + nScanningErrorCount = other.nScanningErrorCount; + nLastScanningErrorBlockHeight = other.nLastScanningErrorBlockHeight; return *this; } + friend bool operator==(const CMasternode& a, const CMasternode& b) { return a.vin == b.vin; diff --git a/src/messagesigner.cpp b/src/messagesigner.cpp index 0b2315d1f03ca..0c42afff9ff7a 100644 --- a/src/messagesigner.cpp +++ b/src/messagesigner.cpp @@ -144,14 +144,3 @@ std::string CSignedMessage::GetSignatureBase64() const return EncodeBase64(&vchSig[0], vchSig.size()); } -void CSignedMessage::swap(CSignedMessage& first, CSignedMessage& second) // nothrow -{ - // enable ADL (not necessary in our case, but good practice) - using std::swap; - - // by swapping the members of two classes, - // the two classes are effectively swapped - swap(first.vchSig, second.vchSig); - swap(first.nMessVersion, second.nMessVersion); -} - diff --git a/src/messagesigner.h b/src/messagesigner.h index 647a74379f037..31847e71c284b 100644 --- a/src/messagesigner.h +++ b/src/messagesigner.h @@ -50,7 +50,6 @@ class CSignedMessage { protected: std::vector vchSig; - void swap(CSignedMessage& first, CSignedMessage& second); // Swap two messages public: int nMessVersion; @@ -59,11 +58,6 @@ class CSignedMessage vchSig(), nMessVersion(MessageVersion::MESS_VER_HASH) {} - CSignedMessage(const CSignedMessage& other) - { - vchSig = other.GetVchSig(); - nMessVersion = other.nMessVersion; - } virtual ~CSignedMessage() {}; // Sign-Verify message diff --git a/src/policy/feerate.h b/src/policy/feerate.h index db9ac37fc8984..4488604a061f4 100644 --- a/src/policy/feerate.h +++ b/src/policy/feerate.h @@ -24,7 +24,6 @@ class CFeeRate CFeeRate() : nSatoshisPerK(0) {} explicit CFeeRate(const CAmount& _nSatoshisPerK) : nSatoshisPerK(_nSatoshisPerK) {} CFeeRate(const CAmount& nFeePaid, size_t nSize); - CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; } CAmount GetFee(size_t size) const; // unit returned is satoshis CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index a8a1ecf483029..b3af3648d1bd5 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -266,6 +266,7 @@ class CTransaction CTransaction(const CMutableTransaction &tx); CTransaction(CMutableTransaction &&tx); + CTransaction(const CTransaction& tx) = default; CTransaction& operator=(const CTransaction& tx); ADD_SERIALIZE_METHODS; diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f181d464bcb39..f4a850106bda5 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -40,13 +40,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFe feeDelta = 0; } -CTxMemPoolEntry::CTxMemPoolEntry(const CTxMemPoolEntry& other) -{ - *this = other; -} - -double -CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const +double CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const { double deltaPriority = ((double)(currentHeight - entryHeight) * inChainInputValue) / nModSize; double dResult = entryPriority + deltaPriority; diff --git a/src/txmempool.h b/src/txmempool.h index 898533c3f149f..c5cce5f0b940a 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -92,7 +92,6 @@ class CTxMemPoolEntry int64_t _nTime, double _entryPriority, unsigned int _entryHeight, bool poolHasNoInputsOf, CAmount _inChainInputValue, bool _spendsCoinbaseOrCoinstake, unsigned int nSigOps); - CTxMemPoolEntry(const CTxMemPoolEntry& other); const CTransaction& GetTx() const { return *this->tx; } std::shared_ptr GetSharedTx() const { return this->tx; }