Pass as constant reference
authorsvost <ya.nowa@yandex.ru>
Sun, 1 May 2016 16:59:56 +0000 (19:59 +0300)
committersvost <ya.nowa@yandex.ru>
Sun, 1 May 2016 16:59:56 +0000 (19:59 +0300)
src/kernel.cpp
src/kernel.h
src/key.cpp
src/key.h

index 769e7a2..422c48e 100644 (file)
@@ -301,7 +301,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64_t& nStake
 
 // The stake modifier used to hash for a stake kernel is chosen as the stake
 // modifier about a selection interval later than the coin generating the kernel
-static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
+static bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
 {
     nStakeModifier = 0;
     if (!mapBlockIndex.count(hashBlockFrom))
@@ -333,7 +333,7 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifi
     return true;
 }
 
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier)
+bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier)
 {
     int nStakeModifierHeight;
     int64_t nStakeModifierTime;
index 8504a59..de4b52d 100644 (file)
@@ -25,7 +25,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64_t& nStake
 
 // The stake modifier used to hash for a stake kernel is chosen as the stake
 // modifier about a selection interval later than the coin generating the kernel
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier);
+bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier);
 
 // Check whether stake kernel meets hash target
 // Sets hashProofOfStake on success return
index 226ee68..5319680 100644 (file)
@@ -399,7 +399,7 @@ bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
 // The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
 // The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
 //                  0x1D = second key with even y, 0x1E = second key with odd y
-bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
+bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
 {
     bool fOk = false;
     auto sig = ECDSA_do_sign(hash.begin(), hash.size(), pkey);
@@ -453,7 +453,7 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
 // This is only slightly more CPU intensive than just verifying it.
 // If this function succeeds, the recovered public key is guaranteed to be valid
 // (the signature is a valid signature of the given data for that key)
-bool CPubKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig)
+bool CPubKey::SetCompactSignature(const uint256 &hash, const std::vector<unsigned char>& vchSig)
 {
     if (vchSig.size() != 65)
         return false;
@@ -531,7 +531,7 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchS
     return ret;
 }
 
-bool CPubKey::VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig)
+bool CPubKey::VerifyCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig)
 {
     CPubKey key;
     if (!key.SetCompactSignature(hash, vchSig))
index cb5a712..a8ed447 100644 (file)
--- a/src/key.h
+++ b/src/key.h
@@ -200,9 +200,9 @@ public:
     }
 
     bool Verify(const uint256& hash, const std::vector<unsigned char>& vchSig) const;
-    bool VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig);
+    bool VerifyCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig);
 
-    bool SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig);
+    bool SetCompactSignature(const uint256 &hash, const std::vector<unsigned char>& vchSig);
 
     // Reserialize to DER
     static bool ReserealizeSignature(std::vector<unsigned char>& vchSig);
@@ -255,7 +255,7 @@ public:
     // The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
     // The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
     //                  0x1D = second key with even y, 0x1E = second key with odd y
-    bool SignCompact(uint256 hash, std::vector<unsigned char>& vchSig);
+    bool SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig);
 
     bool IsValid();