From 64ada2e23a37f3150898d59509d77dbb6551c475 Mon Sep 17 00:00:00 2001 From: svost Date: Sun, 11 Sep 2016 14:26:58 +0300 Subject: [PATCH] Bit cleaner code in scripts files --- src/script.cpp | 42 +++++++++++++++++++++--------------------- src/script.h | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/script.cpp b/src/script.cpp index 0e6d3c0..e12a936 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1234,13 +1234,13 @@ class CSignatureCache { private: // sigdata_type is (signature hash, signature, public key): - typedef tuple, CPubKey > sigdata_type; + typedef tuple, CPubKey > sigdata_type; set< sigdata_type> setValid; boost::shared_mutex cs_sigcache; public: bool - Get(const uint256 &hash, const std::vector& vchSig, const CPubKey& pubKey) + Get(const uint256 &hash, const vector& vchSig, const CPubKey& pubKey) { boost::shared_lock lock(cs_sigcache); @@ -1251,25 +1251,25 @@ public: return false; } - void Set(const uint256 &hash, const std::vector& vchSig, const CPubKey& pubKey) + void Set(const uint256 &hash, const vector& vchSig, const CPubKey& pubKey) { // DoS prevention: limit cache size to less than 10MB // (~200 bytes per cache entry times 50,000 entries) // Since there are a maximum of 20,000 signature operations per block // 50,000 is a reasonable default. - int64_t nMaxCacheSize = GetArg("-maxsigcachesize", 50000); + size_t nMaxCacheSize = GetArgUInt("-maxsigcachesize", 50000u); if (nMaxCacheSize <= 0) return; boost::shared_lock lock(cs_sigcache); - while (static_cast(setValid.size()) > nMaxCacheSize) + while (setValid.size() > nMaxCacheSize) { // Evict a random entry. Random because that helps // foil would-be DoS attackers who might try to pre-generate // and re-use a set of valid signatures just-slightly-greater // than our cache size. auto randomHash = GetRandHash(); - std::vector unused; + vector unused; auto it = setValid.lower_bound(sigdata_type(randomHash, unused, unused)); if (it == setValid.end()) it = setValid.begin(); @@ -1562,7 +1562,7 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, const uint25 return false; } -int ScriptSigArgsExpected(txnouttype t, const std::vector >& vSolutions) +int ScriptSigArgsExpected(txnouttype t, const vector >& vSolutions) { switch (t) { @@ -1767,14 +1767,14 @@ class CAffectedKeysVisitor : public boost::static_visitor { private: const CKeyStore &keystore; CAffectedKeysVisitor& operator=(CAffectedKeysVisitor const&); - std::vector &vKeys; + vector &vKeys; public: - CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} + CAffectedKeysVisitor(const CKeyStore &keystoreIn, vector &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} void Process(const CScript &script) { txnouttype type; - std::vector vDest; + vector vDest; int nRequired; if (ExtractDestinations(script, type, vDest, nRequired)) { for(const CTxDestination &dest : vDest) @@ -1797,7 +1797,7 @@ public: }; -void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector &vKeys) { +void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, vector &vKeys) { CAffectedKeysVisitor(keystore, vKeys).Process(scriptPubKey); } @@ -2107,7 +2107,7 @@ CScript& CScript::operator<<(const uint256& b) CScript& CScript::operator<<(const CPubKey& key) { - std::vector vchKey(key.begin(), key.end()); + vector vchKey(key.begin(), key.end()); return (*this) << vchKey; } @@ -2117,7 +2117,7 @@ CScript& CScript::operator<<(const CBigNum& b) return *this; } -CScript& CScript::operator<<(const std::vector& b) +CScript& CScript::operator<<(const vector& b) { if (b.size() < OP_PUSHDATA1) { @@ -2152,7 +2152,7 @@ CScript& CScript::operator<<(const CScript& b) return *this; } -bool CScript::GetOp(iterator& pc, opcodetype& opcodeRet, std::vector& vchRet) +bool CScript::GetOp(iterator& pc, opcodetype& opcodeRet, vector& vchRet) { // Wrapper so it can be called with either iterator or const_iterator const_iterator pc2 = pc; @@ -2169,7 +2169,7 @@ bool CScript::GetOp(iterator& pc, opcodetype& opcodeRet) return fRet; } -bool CScript::GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector& vchRet) const +bool CScript::GetOp(const_iterator& pc, opcodetype& opcodeRet, vector& vchRet) const { return GetOp2(pc, opcodeRet, &vchRet); } @@ -2179,7 +2179,7 @@ bool CScript::GetOp(const_iterator& pc, opcodetype& opcodeRet) const return GetOp2(pc, opcodeRet, NULL); } -bool CScript::GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector* pvchRet) const +bool CScript::GetOp2(const_iterator& pc, opcodetype& opcodeRet, vector* pvchRet) const { opcodeRet = OP_INVALIDOPCODE; if (pvchRet) @@ -2366,7 +2366,7 @@ bool CScript::HasCanonicalPushes() const while (pc < end()) { opcodetype opcode; - std::vector data; + vector data; if (!GetOp(pc, opcode, data)) return false; if (opcode > OP_16) @@ -2436,7 +2436,7 @@ void CScript::SetAddress(const CBitcoinAddress& dest) } } -void CScript::SetMultisig(int nRequired, const std::vector& keys) +void CScript::SetMultisig(int nRequired, const vector& keys) { this->clear(); @@ -2451,11 +2451,11 @@ void CScript::PrintHex() const printf("CScript(%s)\n", HexStr(begin(), end(), true).c_str()); } -std::string CScript::ToString(bool fShort) const +string CScript::ToString(bool fShort) const { - std::string str; + string str; opcodetype opcode; - std::vector vch; + vector vch; const_iterator pc = begin(); while (pc < end()) { diff --git a/src/script.h b/src/script.h index f2f9a08..85fcf94 100644 --- a/src/script.h +++ b/src/script.h @@ -259,7 +259,7 @@ const char* GetOpName(opcodetype opcode); inline std::string ValueString(const std::vector& vch) { if (vch.size() <= 4) - return strprintf("%d", CBigNum(vch).getint32()); + return std::to_string(CBigNum(vch).getint32()); else return HexStr(vch); } -- 1.7.1