From b51edb58fc07b51ec776efcce3b950f9b742366f Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 7 Jun 2013 15:14:10 -0700 Subject: [PATCH] Replace std::vector with Blob --- modules/ripple_basics/ripple_basics.h | 1 + modules/ripple_basics/types/ripple_Types.h | 13 +++++ modules/ripple_basics/types/ripple_UInt256.h | 6 +-- .../utility/ripple_HashUtilities.h | 2 +- .../utility/ripple_StringUtilities.cpp | 8 +-- .../utility/ripple_StringUtilities.h | 10 ++-- modules/ripple_data/crypto/ripple_Base58.cpp | 18 +++---- modules/ripple_data/crypto/ripple_Base58.h | 12 ++--- .../ripple_data/crypto/ripple_Base58Data.cpp | 6 +-- .../ripple_data/crypto/ripple_Base58Data.h | 4 +- modules/ripple_data/crypto/ripple_CBigNum.cpp | 16 +++--- modules/ripple_data/crypto/ripple_CBigNum.h | 6 +-- modules/ripple_data/crypto/ripple_CKey.h | 14 ++--- .../ripple_data/crypto/ripple_CKeyECIES.cpp | 16 +++--- .../protocol/ripple_RippleAddress.cpp | 54 +++++++++---------- .../protocol/ripple_RippleAddress.h | 44 +++++++-------- .../ripple_data/protocol/ripple_STAmount.cpp | 10 ++-- .../protocol/ripple_SerializedObject.cpp | 8 +-- .../protocol/ripple_SerializedObject.h | 4 +- .../protocol/ripple_SerializedTypes.cpp | 6 +-- .../protocol/ripple_SerializedTypes.h | 20 +++---- .../protocol/ripple_Serializer.cpp | 36 ++++++------- .../ripple_data/protocol/ripple_Serializer.h | 52 +++++++++--------- newcoin.vcxproj | 1 + newcoin.vcxproj.filters | 3 ++ src/cpp/database/SqliteDatabase.cpp | 10 ++-- src/cpp/database/SqliteDatabase.h | 6 +-- src/cpp/database/database.cpp | 4 +- src/cpp/database/database.h | 4 +- src/cpp/ripple/AcceptedLedger.h | 2 +- src/cpp/ripple/AccountItems.h | 2 +- src/cpp/ripple/AccountSetTransactor.cpp | 4 +- src/cpp/ripple/AccountState.cpp | 2 +- src/cpp/ripple/AccountState.h | 2 +- src/cpp/ripple/Application.h | 2 +- src/cpp/ripple/Interpreter.cpp | 2 +- src/cpp/ripple/Interpreter.h | 4 +- src/cpp/ripple/Ledger.cpp | 4 +- src/cpp/ripple/Ledger.h | 2 +- src/cpp/ripple/LedgerAcquire.cpp | 18 +++---- src/cpp/ripple/LedgerAcquire.h | 8 +-- src/cpp/ripple/LedgerConsensus.cpp | 12 ++--- src/cpp/ripple/LedgerConsensus.h | 8 +-- src/cpp/ripple/LedgerProposal.cpp | 4 +- src/cpp/ripple/LedgerProposal.h | 4 +- src/cpp/ripple/NetworkOPs.cpp | 10 ++-- src/cpp/ripple/NetworkOPs.h | 20 +++---- src/cpp/ripple/NicknameState.h | 2 +- src/cpp/ripple/RPCHandler.cpp | 10 ++-- src/cpp/ripple/RPCServer.h | 2 +- src/cpp/ripple/RippleState.h | 2 +- src/cpp/ripple/SHAMap.cpp | 12 ++--- src/cpp/ripple/SHAMap.h | 40 +++++++------- src/cpp/ripple/SHAMapNodes.cpp | 2 +- src/cpp/ripple/SHAMapSync.cpp | 16 +++--- src/cpp/ripple/SHAMapSync.h | 12 ++--- src/cpp/ripple/SerializedTransaction.cpp | 6 +-- src/cpp/ripple/SerializedTransaction.h | 6 +-- src/cpp/ripple/SerializedValidation.cpp | 6 +-- src/cpp/ripple/SerializedValidation.h | 4 +- src/cpp/ripple/Transaction.cpp | 2 +- src/cpp/ripple/Transaction.h | 4 +- src/cpp/ripple/TransactionAcquire.cpp | 8 +-- src/cpp/ripple/TransactionMeta.cpp | 2 +- src/cpp/ripple/TransactionMeta.h | 2 +- src/cpp/ripple/UpdateTables.cpp | 2 +- src/cpp/ripple/Wallet.cpp | 2 +- src/cpp/ripple/WalletAddTransactor.cpp | 4 +- src/cpp/ripple/ripple_HashedObject.h | 6 +-- src/cpp/ripple/ripple_HashedObjectStore.cpp | 12 ++--- src/cpp/ripple/ripple_HashedObjectStore.h | 6 +-- src/cpp/ripple/ripple_Peer.cpp | 12 ++--- 72 files changed, 352 insertions(+), 334 deletions(-) create mode 100644 modules/ripple_basics/types/ripple_Types.h diff --git a/modules/ripple_basics/ripple_basics.h b/modules/ripple_basics/ripple_basics.h index ad6efb64af..b41cb5523c 100644 --- a/modules/ripple_basics/ripple_basics.h +++ b/modules/ripple_basics/ripple_basics.h @@ -134,6 +134,7 @@ namespace boost { #include "containers/ripple_SecureAllocator.h" #include "containers/ripple_TaggedCache.h" +#include "types/ripple_Types.h" #include "utility/ripple_ByteOrder.h" #include "utility/ripple_DiffieHellmanUtil.h" #include "utility/ripple_InstanceCounter.h" diff --git a/modules/ripple_basics/types/ripple_Types.h b/modules/ripple_basics/types/ripple_Types.h new file mode 100644 index 0000000000..d92d9d6bb8 --- /dev/null +++ b/modules/ripple_basics/types/ripple_Types.h @@ -0,0 +1,13 @@ + +//------------------------------------------------------------------------------ + +#ifndef RIPPLE_TYPES_H +#define RIPPLE_TYPES_H + +/** Storage for linear binary data. + + Blocks of binary data appear often in various idioms and structures. +*/ +typedef std::vector Blob; + +#endif diff --git a/modules/ripple_basics/types/ripple_UInt256.h b/modules/ripple_basics/types/ripple_UInt256.h index 0e4b934510..0cfc1282b8 100644 --- a/modules/ripple_basics/types/ripple_UInt256.h +++ b/modules/ripple_basics/types/ripple_UInt256.h @@ -415,7 +415,7 @@ public: pn[i] = b.pn[i]; } - explicit uint128(const std::vector& vch) + explicit uint128(Blob const& vch) { if (vch.size() == size()) memcpy(pn, &vch[0], size()); @@ -472,7 +472,7 @@ public: SetHex(str); } - explicit uint256(const std::vector& vch) + explicit uint256(Blob const& vch) { if (vch.size() == sizeof(pn)) memcpy(pn, &vch[0], sizeof(pn)); @@ -689,7 +689,7 @@ public: SetHex(str); } - explicit uint160(const std::vector& vch) + explicit uint160(Blob const& vch) { if (vch.size() == sizeof(pn)) memcpy(pn, &vch[0], sizeof(pn)); diff --git a/modules/ripple_basics/utility/ripple_HashUtilities.h b/modules/ripple_basics/utility/ripple_HashUtilities.h index de199c8868..68af7cd87c 100644 --- a/modules/ripple_basics/utility/ripple_HashUtilities.h +++ b/modules/ripple_basics/utility/ripple_HashUtilities.h @@ -51,7 +51,7 @@ inline uint256 SHA256Hash(const T1 p1begin, const T1 p1end, return hash2; } -inline uint160 Hash160(const std::vector& vch) +inline uint160 Hash160(Blob const& vch) { uint256 hash1; SHA256(&vch[0], vch.size(), (unsigned char*)&hash1); diff --git a/modules/ripple_basics/utility/ripple_StringUtilities.cpp b/modules/ripple_basics/utility/ripple_StringUtilities.cpp index 79a0d031d5..15eb7bc0e9 100644 --- a/modules/ripple_basics/utility/ripple_StringUtilities.cpp +++ b/modules/ripple_basics/utility/ripple_StringUtilities.cpp @@ -90,7 +90,7 @@ int strUnHex(std::string& strDst, const std::string& strSrc) return iBytes; } -std::vector strUnHex(const std::string& strSrc) +Blob strUnHex(const std::string& strSrc) { std::string strTmp; @@ -113,9 +113,9 @@ uint64_t uintFromHex(const std::string& strSrc) // Misc string // -std::vector strCopy(const std::string& strSrc) +Blob strCopy(const std::string& strSrc) { - std::vector vucDst; + Blob vucDst; vucDst.resize(strSrc.size()); @@ -124,7 +124,7 @@ std::vector strCopy(const std::string& strSrc) return vucDst; } -std::string strCopy(const std::vector& vucSrc) +std::string strCopy(Blob const& vucSrc) { std::string strDst; diff --git a/modules/ripple_basics/utility/ripple_StringUtilities.h b/modules/ripple_basics/utility/ripple_StringUtilities.h index 05efbd97ff..1ba891ba54 100644 --- a/modules/ripple_basics/utility/ripple_StringUtilities.h +++ b/modules/ripple_basics/utility/ripple_StringUtilities.h @@ -99,7 +99,7 @@ inline const std::string strHex(const std::string& strSrc) return strHex(strSrc.begin(), strSrc.size()); } -inline std::string strHex(const std::vector& vucData) +inline std::string strHex(Blob const& vucData) { return strHex(vucData.begin(), vucData.size()); } @@ -117,7 +117,7 @@ inline static std::string sqlEscape(const std::string& strSrc) return str(boost::format(f) % strHex(strSrc)); } -inline static std::string sqlEscape(const std::vector& vecSrc) +inline static std::string sqlEscape(Blob const& vecSrc) { size_t size = vecSrc.size(); if (size == 0) @@ -156,10 +156,10 @@ int strUnHex(std::string& strDst, const std::string& strSrc); uint64_t uintFromHex(const std::string& strSrc); -std::vector strUnHex(const std::string& strSrc); +Blob strUnHex(const std::string& strSrc); -std::vector strCopy(const std::string& strSrc); -std::string strCopy(const std::vector& vucSrc); +Blob strCopy(const std::string& strSrc); +std::string strCopy(Blob const& vucSrc); bool parseIpPort(const std::string& strSource, std::string& strIP, int& iPort); bool parseQuality(const std::string& strSource, uint32& uQuality); diff --git a/modules/ripple_data/crypto/ripple_Base58.cpp b/modules/ripple_data/crypto/ripple_Base58.cpp index e8af246bcf..3a7924b3b1 100644 --- a/modules/ripple_data/crypto/ripple_Base58.cpp +++ b/modules/ripple_data/crypto/ripple_Base58.cpp @@ -58,7 +58,7 @@ std::string Base58::encode (const unsigned char* pbegin, const unsigned char* pe // Convert big endian data to little endian // Extra zero at the end make sure bignum will interpret as a positive number - std::vector vchTmp(pend-pbegin+1, 0); + Blob vchTmp(pend-pbegin+1, 0); std::reverse_copy(pbegin, pend, vchTmp.begin()); // Convert little endian data to bignum @@ -89,21 +89,21 @@ std::string Base58::encode (const unsigned char* pbegin, const unsigned char* pe return str; } -std::string Base58::encode (const std::vector& vch) +std::string Base58::encode (Blob const& vch) { return encode (&vch[0], &vch[0] + vch.size()); } -std::string Base58::encodeWithCheck (const std::vector& vchIn) +std::string Base58::encodeWithCheck (Blob const& vchIn) { // add 4-byte hash check to the end - std::vector vch(vchIn); + Blob vch(vchIn); uint256 hash = SHA256Hash(vch.begin(), vch.end()); vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4); return encode (vch); } -bool Base58::decode (const char* psz, std::vector& vchRet, const char* pAlpha) +bool Base58::decode (const char* psz, Blob & vchRet, const char* pAlpha) { assert (pAlpha != 0); @@ -134,7 +134,7 @@ bool Base58::decode (const char* psz, std::vector& vchRet, const } // Get bignum as little endian data - std::vector vchTmp = bn.getvch(); + Blob vchTmp = bn.getvch(); // Trim off sign byte if present if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80) @@ -151,12 +151,12 @@ bool Base58::decode (const char* psz, std::vector& vchRet, const return true; } -bool Base58::decode (const std::string& str, std::vector& vchRet) +bool Base58::decode (const std::string& str, Blob & vchRet) { return decode (str.c_str(), vchRet); } -bool Base58::decodeWithCheck (const char* psz, std::vector& vchRet, const char* pAlphabet) +bool Base58::decodeWithCheck (const char* psz, Blob & vchRet, const char* pAlphabet) { assert (pAlphabet != NULL); @@ -177,7 +177,7 @@ bool Base58::decodeWithCheck (const char* psz, std::vector& vchRe return true; } -bool Base58::decodeWithCheck (const std::string& str, std::vector& vchRet, const char* pAlphabet) +bool Base58::decodeWithCheck (const std::string& str, Blob & vchRet, const char* pAlphabet) { return decodeWithCheck (str.c_str(), vchRet, pAlphabet); } diff --git a/modules/ripple_data/crypto/ripple_Base58.h b/modules/ripple_data/crypto/ripple_Base58.h index 8a308d15bc..be402ed1a6 100644 --- a/modules/ripple_data/crypto/ripple_Base58.h +++ b/modules/ripple_data/crypto/ripple_Base58.h @@ -45,13 +45,13 @@ public: static char const* getTestnetAlphabet (); static std::string encode (const unsigned char* pbegin, const unsigned char* pend); - static std::string encode (const std::vector& vch); - static std::string encodeWithCheck (const std::vector& vchIn); + static std::string encode (Blob const& vch); + static std::string encodeWithCheck (Blob const& vchIn); - static bool decode (const char* psz, std::vector& vchRet, const char* pAlphabet=getCurrentAlphabet ()); - static bool decode (const std::string& str, std::vector& vchRet); - static bool decodeWithCheck (const char* psz, std::vector& vchRet, const char* pAlphabet=getCurrentAlphabet ()); - static bool decodeWithCheck (const std::string& str, std::vector& vchRet, const char* pAlphabet); + static bool decode (const char* psz, Blob & vchRet, const char* pAlphabet=getCurrentAlphabet ()); + static bool decode (const std::string& str, Blob & vchRet); + static bool decodeWithCheck (const char* psz, Blob & vchRet, const char* pAlphabet=getCurrentAlphabet ()); + static bool decodeWithCheck (const std::string& str, Blob & vchRet, const char* pAlphabet); private: static char const* s_currentAlphabet; diff --git a/modules/ripple_data/crypto/ripple_Base58Data.cpp b/modules/ripple_data/crypto/ripple_Base58Data.cpp index 224f91411c..1fec8dcbcd 100644 --- a/modules/ripple_data/crypto/ripple_Base58Data.cpp +++ b/modules/ripple_data/crypto/ripple_Base58Data.cpp @@ -40,7 +40,7 @@ CBase58Data::~CBase58Data() memset(&vchData[0], 0, vchData.size()); } -void CBase58Data::SetData(int nVersionIn, const std::vector& vchDataIn) +void CBase58Data::SetData(int nVersionIn, Blob const& vchDataIn) { nVersion = nVersionIn; vchData = vchDataIn; @@ -61,7 +61,7 @@ void CBase58Data::SetData(int nVersionIn, const unsigned char *pbegin, const uns bool CBase58Data::SetString(const char* psz, unsigned char version, const char* pAlphabet) { - std::vector vchTemp; + Blob vchTemp; Base58::decodeWithCheck (psz, vchTemp, pAlphabet); if (vchTemp.empty() || vchTemp[0] != version) { @@ -84,7 +84,7 @@ bool CBase58Data::SetString(const std::string& str, unsigned char version) std::string CBase58Data::ToString() const { - std::vector vch(1, nVersion); + Blob vch(1, nVersion); vch.insert(vch.end(), vchData.begin(), vchData.end()); diff --git a/modules/ripple_data/crypto/ripple_Base58Data.h b/modules/ripple_data/crypto/ripple_Base58Data.h index 58ed874e07..4a0ce364dd 100644 --- a/modules/ripple_data/crypto/ripple_Base58Data.h +++ b/modules/ripple_data/crypto/ripple_Base58Data.h @@ -35,12 +35,12 @@ class CBase58Data { protected: unsigned char nVersion; - std::vector vchData; + Blob vchData; CBase58Data(); ~CBase58Data(); - void SetData(int nVersionIn, const std::vector& vchDataIn); + void SetData(int nVersionIn, Blob const& vchDataIn); void SetData(int nVersionIn, const void* pdata, size_t nSize); void SetData(int nVersionIn, const unsigned char *pbegin, const unsigned char *pend); diff --git a/modules/ripple_data/crypto/ripple_CBigNum.cpp b/modules/ripple_data/crypto/ripple_CBigNum.cpp index f577b6c6d0..dbda84f569 100644 --- a/modules/ripple_data/crypto/ripple_CBigNum.cpp +++ b/modules/ripple_data/crypto/ripple_CBigNum.cpp @@ -41,7 +41,7 @@ CBigNum::CBigNum(unsigned int n) { BN_init(this); setulong(n); } CBigNum::CBigNum(uint64 n) { BN_init(this); setuint64(n); } CBigNum::CBigNum(uint256 n) { BN_init(this); setuint256(n); } -CBigNum::CBigNum(const std::vector& vch) +CBigNum::CBigNum(Blob const& vch) { BN_init(this); setvch(vch); @@ -154,9 +154,9 @@ uint256 CBigNum::getuint256() return ret; } -void CBigNum::setvch(const std::vector& vch) +void CBigNum::setvch(Blob const& vch) { - std::vector vch2(vch.size() + 4); + Blob vch2(vch.size() + 4); unsigned int nSize = vch.size(); // BIGNUM's byte stream format expects 4 bytes of // big endian size data info at the front @@ -169,12 +169,12 @@ void CBigNum::setvch(const std::vector& vch) BN_mpi2bn(&vch2[0], vch2.size(), this); } -std::vector CBigNum::getvch() const +Blob CBigNum::getvch() const { unsigned int nSize = BN_bn2mpi(this, NULL); if (nSize < 4) - return std::vector(); - std::vector vch(nSize); + return Blob (); + Blob vch(nSize); BN_bn2mpi(this, &vch[0]); vch.erase(vch.begin(), vch.begin() + 4); reverse(vch.begin(), vch.end()); @@ -184,7 +184,7 @@ std::vector CBigNum::getvch() const CBigNum& CBigNum::SetCompact(unsigned int nCompact) { unsigned int nSize = nCompact >> 24; - std::vector vch(4 + nSize); + Blob vch(4 + nSize); vch[3] = nSize; if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff; if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff; @@ -196,7 +196,7 @@ CBigNum& CBigNum::SetCompact(unsigned int nCompact) unsigned int CBigNum::GetCompact() const { unsigned int nSize = BN_bn2mpi(this, NULL); - std::vector vch(nSize); + Blob vch(nSize); nSize -= 4; BN_bn2mpi(this, &vch[0]); unsigned int nCompact = nSize << 24; diff --git a/modules/ripple_data/crypto/ripple_CBigNum.h b/modules/ripple_data/crypto/ripple_CBigNum.h index be9ebc98af..63259d1d46 100644 --- a/modules/ripple_data/crypto/ripple_CBigNum.h +++ b/modules/ripple_data/crypto/ripple_CBigNum.h @@ -70,7 +70,7 @@ public: CBigNum(unsigned int n); CBigNum(uint64 n); explicit CBigNum(uint256 n); - explicit CBigNum(const std::vector& vch); + explicit CBigNum(Blob const& vch); ~CBigNum(); void setuint(unsigned int n); @@ -81,8 +81,8 @@ public: void setuint64(uint64 n); void setuint256(const uint256& n); uint256 getuint256(); - void setvch(const std::vector& vch); - std::vector getvch() const; + void setvch(Blob const& vch); + Blob getvch() const; CBigNum& SetCompact(unsigned int nCompact); unsigned int GetCompact() const; void SetHex(const std::string& str); diff --git a/modules/ripple_data/crypto/ripple_CKey.h b/modules/ripple_data/crypto/ripple_CKey.h index f35148c1c4..4670a29fbc 100644 --- a/modules/ripple_data/crypto/ripple_CKey.h +++ b/modules/ripple_data/crypto/ripple_CKey.h @@ -224,7 +224,7 @@ public: return true; } - bool SetPubKey(const std::vector& vchPubKey) + bool SetPubKey(Blob const& vchPubKey) { return SetPubKey(&vchPubKey[0], vchPubKey.size()); } @@ -234,13 +234,13 @@ public: return SetPubKey(pubKey.data(), pubKey.size()); } - std::vector GetPubKey() const + Blob GetPubKey() const { unsigned int nSize = i2o_ECPublicKey(pkey, NULL); assert(nSize<=33); if (!nSize) throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed"); - std::vector vchPubKey(33, 0); + Blob vchPubKey(33, 0); unsigned char* pbegin = &vchPubKey[0]; if (i2o_ECPublicKey(pkey, &pbegin) != nSize) throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size"); @@ -248,7 +248,7 @@ public: return vchPubKey; } - bool Sign(const uint256& hash, std::vector& vchSig) + bool Sign(const uint256& hash, Blob & vchSig) { unsigned char pchSig[10000]; unsigned int nSize = 0; @@ -272,7 +272,7 @@ public: return true; } - bool Verify(const uint256& hash, const std::vector& vchSig) const + bool Verify(const uint256& hash, Blob const& vchSig) const { return Verify(hash, &vchSig[0], vchSig.size()); } @@ -289,8 +289,8 @@ public: // encrypt/decrypt functions with integrity checking. // Note that the other side must somehow know what keys to use - std::vector encryptECIES(CKey& otherKey, const std::vector& plaintext); - std::vector decryptECIES(CKey& otherKey, const std::vector& ciphertext); + Blob encryptECIES(CKey& otherKey, Blob const& plaintext); + Blob decryptECIES(CKey& otherKey, Blob const& ciphertext); }; #endif diff --git a/modules/ripple_data/crypto/ripple_CKeyECIES.cpp b/modules/ripple_data/crypto/ripple_CKeyECIES.cpp index 307b17b7e8..f1bd8f1bf5 100644 --- a/modules/ripple_data/crypto/ripple_CKeyECIES.cpp +++ b/modules/ripple_data/crypto/ripple_CKeyECIES.cpp @@ -71,7 +71,7 @@ void CKey::getECIESSecret(CKey& otherKey, ECIES_ENC_KEY_TYPE& enc_key, ECIES_HMA memset(hbuf, 0, ECIES_KEY_LENGTH); } -static ECIES_HMAC_TYPE makeHMAC(const ECIES_HMAC_KEY_TYPE& secret, const std::vector& data) +static ECIES_HMAC_TYPE makeHMAC(const ECIES_HMAC_KEY_TYPE& secret, Blob const& data) { HMAC_CTX ctx; HMAC_CTX_init(&ctx); @@ -101,7 +101,7 @@ static ECIES_HMAC_TYPE makeHMAC(const ECIES_HMAC_KEY_TYPE& secret, const std::ve return ret; } -std::vector CKey::encryptECIES(CKey& otherKey, const std::vector& plaintext) +Blob CKey::encryptECIES(CKey& otherKey, Blob const& plaintext) { ECIES_ENC_IV_TYPE iv; @@ -125,7 +125,7 @@ std::vector CKey::encryptECIES(CKey& otherKey, const std::vector< } secret.zero(); - std::vector out(plaintext.size() + ECIES_HMAC_SIZE + ECIES_ENC_KEY_SIZE + ECIES_ENC_BLK_SIZE, 0); + Blob out(plaintext.size() + ECIES_HMAC_SIZE + ECIES_ENC_KEY_SIZE + ECIES_ENC_BLK_SIZE, 0); int len = 0, bytesWritten; // output IV @@ -169,7 +169,7 @@ std::vector CKey::encryptECIES(CKey& otherKey, const std::vector< return out; } -std::vector CKey::decryptECIES(CKey& otherKey, const std::vector& ciphertext) +Blob CKey::decryptECIES(CKey& otherKey, Blob const& ciphertext) { // minimum ciphertext = IV + HMAC + 1 block if (ciphertext.size() < ((2 * ECIES_ENC_BLK_SIZE) + ECIES_HMAC_SIZE) ) @@ -208,7 +208,7 @@ std::vector CKey::decryptECIES(CKey& otherKey, const std::vector< } // decrypt plaintext (after IV and encrypted mac) - std::vector plaintext(ciphertext.size() - ECIES_HMAC_SIZE - ECIES_ENC_BLK_SIZE); + Blob plaintext(ciphertext.size() - ECIES_HMAC_SIZE - ECIES_ENC_BLK_SIZE); outlen = plaintext.size(); if (EVP_DecryptUpdate(&ctx, &(plaintext.front()), &outlen, &(ciphertext.front()) + ECIES_ENC_BLK_SIZE + ECIES_HMAC_SIZE + 1, @@ -265,17 +265,17 @@ bool checkECIES(void) } // generate message - std::vector message(4096); + Blob message(4096); int msglen = i%3000; RandomNumbers::getInstance ().fillBytes (&message.front(), msglen); message.resize(msglen); // encrypt message with sender's private key and recipient's public key - std::vector ciphertext = senderPriv.encryptECIES(recipientPub, message); + Blob ciphertext = senderPriv.encryptECIES(recipientPub, message); // decrypt message with recipient's private key and sender's public key - std::vector decrypt = recipientPriv.decryptECIES(senderPub, ciphertext); + Blob decrypt = recipientPriv.decryptECIES(senderPub, ciphertext); if (decrypt != message) { diff --git a/modules/ripple_data/protocol/ripple_RippleAddress.cpp b/modules/ripple_data/protocol/ripple_RippleAddress.cpp index 8f6a4f8363..da16b8ef2c 100644 --- a/modules/ripple_data/protocol/ripple_RippleAddress.cpp +++ b/modules/ripple_data/protocol/ripple_RippleAddress.cpp @@ -55,7 +55,7 @@ RippleAddress RippleAddress::createNodePublic(const RippleAddress& naSeed) return naNew; } -RippleAddress RippleAddress::createNodePublic(const std::vector& vPublic) +RippleAddress RippleAddress::createNodePublic(Blob const& vPublic) { RippleAddress naNew; @@ -87,7 +87,7 @@ uint160 RippleAddress::getNodeID() const throw std::runtime_error(str(boost::format("bad source: %d") % int(nVersion))); } } -const std::vector& RippleAddress::getNodePublic() const +Blob const& RippleAddress::getNodePublic() const { switch (nVersion) { case VER_NONE: @@ -122,14 +122,14 @@ bool RippleAddress::setNodePublic(const std::string& strPublic) return mIsValid; } -void RippleAddress::setNodePublic(const std::vector& vPublic) +void RippleAddress::setNodePublic(Blob const& vPublic) { mIsValid = true; SetData(VER_NODE_PUBLIC, vPublic); } -bool RippleAddress::verifyNodePublic(const uint256& hash, const std::vector& vchSig) const +bool RippleAddress::verifyNodePublic(const uint256& hash, Blob const& vchSig) const { CKey pubkey = CKey(); bool bVerified; @@ -149,7 +149,7 @@ bool RippleAddress::verifyNodePublic(const uint256& hash, const std::vector vchSig(strSig.begin(), strSig.end()); + Blob vchSig(strSig.begin(), strSig.end()); return verifyNodePublic(hash, vchSig); } @@ -171,7 +171,7 @@ RippleAddress RippleAddress::createNodePrivate(const RippleAddress& naSeed) return naNew; } -const std::vector& RippleAddress::getNodePrivateData() const +Blob const& RippleAddress::getNodePrivateData() const { switch (nVersion) { case VER_NONE: @@ -220,7 +220,7 @@ bool RippleAddress::setNodePrivate(const std::string& strPrivate) return mIsValid; } -void RippleAddress::setNodePrivate(const std::vector& vPrivate) +void RippleAddress::setNodePrivate(Blob const& vPrivate) { mIsValid = true; @@ -234,7 +234,7 @@ void RippleAddress::setNodePrivate(uint256 hash256) SetData(VER_NODE_PRIVATE, hash256.begin(), 32); } -void RippleAddress::signNodePrivate(const uint256& hash, std::vector& vchSig) const +void RippleAddress::signNodePrivate(const uint256& hash, Blob & vchSig) const { CKey ckPrivKey; @@ -267,7 +267,7 @@ uint160 RippleAddress::getAccountID() const } static boost::mutex rncLock; -static boost::unordered_map< std::vector, std::string > rncMap; +static boost::unordered_map< Blob , std::string > rncMap; std::string RippleAddress::humanAccountID() const { @@ -278,7 +278,7 @@ std::string RippleAddress::humanAccountID() const case VER_ACCOUNT_ID: { boost::mutex::scoped_lock sl(rncLock); - boost::unordered_map< std::vector, std::string >::iterator it = rncMap.find(vchData); + boost::unordered_map< Blob , std::string >::iterator it = rncMap.find(vchData); if (it != rncMap.end()) return it->second; if (rncMap.size() > 10000) @@ -337,7 +337,7 @@ RippleAddress RippleAddress::createAccountPublic(const RippleAddress& naGenerato return naNew; } -const std::vector& RippleAddress::getAccountPublic() const +Blob const& RippleAddress::getAccountPublic() const { switch (nVersion) { case VER_NONE: @@ -379,7 +379,7 @@ bool RippleAddress::setAccountPublic(const std::string& strPublic) return mIsValid; } -void RippleAddress::setAccountPublic(const std::vector& vPublic) +void RippleAddress::setAccountPublic(Blob const& vPublic) { mIsValid = true; @@ -393,7 +393,7 @@ void RippleAddress::setAccountPublic(const RippleAddress& generator, int seq) setAccountPublic(pubkey.GetPubKey()); } -bool RippleAddress::accountPublicVerify(const uint256& uHash, const std::vector& vucSig) const +bool RippleAddress::accountPublicVerify(const uint256& uHash, Blob const& vucSig) const { CKey ckPublic; bool bVerified; @@ -469,7 +469,7 @@ bool RippleAddress::setAccountPrivate(const std::string& strPrivate) return mIsValid; } -void RippleAddress::setAccountPrivate(const std::vector& vPrivate) +void RippleAddress::setAccountPrivate(Blob const& vPrivate) { mIsValid = true; @@ -494,7 +494,7 @@ void RippleAddress::setAccountPrivate(const RippleAddress& naGenerator, const Ri setAccountPrivate(uPrivKey); } -bool RippleAddress::accountPrivateSign(const uint256& uHash, std::vector& vucSig) const +bool RippleAddress::accountPrivateSign(const uint256& uHash, Blob & vucSig) const { CKey ckPrivate; bool bResult; @@ -515,7 +515,7 @@ bool RippleAddress::accountPrivateSign(const uint256& uHash, std::vector& vucSig) const +bool RippleAddress::accountPrivateVerify(const uint256& uHash, Blob const& vucSig) const { CKey ckPrivate; bool bVerified; @@ -535,11 +535,11 @@ bool RippleAddress::accountPrivateVerify(const uint256& uHash, const std::vector } #endif -std::vector RippleAddress::accountPrivateEncrypt(const RippleAddress& naPublicTo, const std::vector& vucPlainText) const +Blob RippleAddress::accountPrivateEncrypt(const RippleAddress& naPublicTo, Blob const& vucPlainText) const { CKey ckPrivate; CKey ckPublic; - std::vector vucCipherText; + Blob vucCipherText; if (!ckPublic.SetPubKey(naPublicTo.getAccountPublic())) { @@ -566,11 +566,11 @@ std::vector RippleAddress::accountPrivateEncrypt(const RippleAddr return vucCipherText; } -std::vector RippleAddress::accountPrivateDecrypt(const RippleAddress& naPublicFrom, const std::vector& vucCipherText) const +Blob RippleAddress::accountPrivateDecrypt(const RippleAddress& naPublicFrom, Blob const& vucCipherText) const { CKey ckPrivate; CKey ckPublic; - std::vector vucPlainText; + Blob vucPlainText; if (!ckPublic.SetPubKey(naPublicFrom.getAccountPublic())) { @@ -619,7 +619,7 @@ BIGNUM* RippleAddress::getGeneratorBN() const return ret; } -const std::vector& RippleAddress::getGenerator() const +Blob const& RippleAddress::getGenerator() const { // returns the public generator switch (nVersion) { case VER_NONE: @@ -655,7 +655,7 @@ bool RippleAddress::setGenerator(const std::string& strGenerator) return mIsValid; } -void RippleAddress::setGenerator(const std::vector& vPublic) +void RippleAddress::setGenerator(Blob const& vPublic) { mIsValid = true; @@ -738,7 +738,7 @@ int RippleAddress::setSeed1751(const std::string& strHuman1751) if (1 == iResult) { - std::vector vchLittle(strKey.rbegin(), strKey.rend()); + Blob vchLittle(strKey.rbegin(), strKey.rend()); uint128 uSeed(vchLittle); setSeed(uSeed); @@ -844,9 +844,9 @@ BOOST_AUTO_TEST_CASE( check_crypto ) BOOST_CHECK_MESSAGE(naNodePrivate.humanNodePrivate() == "pnen77YEeUd4fFKG7iycBWcwKpTaeFRkW2WFostaATy1DSupwXe", naNodePrivate.humanNodePrivate()); // Check node signing. - std::vector vucTextSrc = strCopy("Hello, nurse!"); + Blob vucTextSrc = strCopy("Hello, nurse!"); uint256 uHash = Serializer::getSHA512Half(vucTextSrc); - std::vector vucTextSig; + Blob vucTextSig; naNodePrivate.signNodePrivate(uHash, vucTextSig); BOOST_CHECK_MESSAGE(naNodePublic.verifyNodePublic(uHash, vucTextSig), "Verify failed."); @@ -882,9 +882,9 @@ BOOST_AUTO_TEST_CASE( check_crypto ) BOOST_CHECK_MESSAGE(!naAccountPublic0.accountPublicVerify(uHash, vucTextSig), "Anti-verify failed."); // Check account encryption. - std::vector vucTextCipher + Blob vucTextCipher = naAccountPrivate0.accountPrivateEncrypt(naAccountPublic1, vucTextSrc); - std::vector vucTextRecovered + Blob vucTextRecovered = naAccountPrivate1.accountPrivateDecrypt(naAccountPublic0, vucTextCipher); BOOST_CHECK_MESSAGE(vucTextSrc == vucTextRecovered, "Encrypt-decrypt failed."); diff --git a/modules/ripple_data/protocol/ripple_RippleAddress.h b/modules/ripple_data/protocol/ripple_RippleAddress.h index 4a2ff7d03d..4526c8d94c 100644 --- a/modules/ripple_data/protocol/ripple_RippleAddress.h +++ b/modules/ripple_data/protocol/ripple_RippleAddress.h @@ -36,31 +36,31 @@ public: // Node Public - Also used for Validators // uint160 getNodeID() const; - const std::vector& getNodePublic() const; + Blob const& getNodePublic() const; std::string humanNodePublic() const; bool setNodePublic(const std::string& strPublic); - void setNodePublic(const std::vector& vPublic); - bool verifyNodePublic(const uint256& hash, const std::vector& vchSig) const; + void setNodePublic(Blob const& vPublic); + bool verifyNodePublic(const uint256& hash, Blob const& vchSig) const; bool verifyNodePublic(const uint256& hash, const std::string& strSig) const; static RippleAddress createNodePublic(const RippleAddress& naSeed); - static RippleAddress createNodePublic(const std::vector& vPublic); + static RippleAddress createNodePublic(Blob const& vPublic); static RippleAddress createNodePublic(const std::string& strPublic); // // Node Private // - const std::vector& getNodePrivateData() const; + Blob const& getNodePrivateData() const; uint256 getNodePrivate() const; std::string humanNodePrivate() const; bool setNodePrivate(const std::string& strPrivate); - void setNodePrivate(const std::vector& vPrivate); + void setNodePrivate(Blob const& vPrivate); void setNodePrivate(uint256 hash256); - void signNodePrivate(const uint256& hash, std::vector& vchSig) const; + void signNodePrivate(const uint256& hash, Blob & vchSig) const; static RippleAddress createNodePrivate(const RippleAddress& naSeed); @@ -82,23 +82,23 @@ public: static std::string createHumanAccountID(const uint160& uiAccountID) { return createAccountID(uiAccountID).humanAccountID(); } - static std::string createHumanAccountID(const std::vector& vPrivate) + static std::string createHumanAccountID(Blob const& vPrivate) { return createAccountPrivate(vPrivate).humanAccountID(); } // // Accounts Public // - const std::vector& getAccountPublic() const; + Blob const& getAccountPublic() const; std::string humanAccountPublic() const; bool setAccountPublic(const std::string& strPublic); - void setAccountPublic(const std::vector& vPublic); + void setAccountPublic(Blob const& vPublic); void setAccountPublic(const RippleAddress& generator, int seq); - bool accountPublicVerify(const uint256& uHash, const std::vector& vucSig) const; + bool accountPublicVerify(const uint256& uHash, Blob const& vucSig) const; - static RippleAddress createAccountPublic(const std::vector& vPublic) + static RippleAddress createAccountPublic(Blob const& vPublic) { RippleAddress naNew; @@ -107,7 +107,7 @@ public: return naNew; } - static std::string createHumanAccountPublic(const std::vector& vPublic) { + static std::string createHumanAccountPublic(Blob const& vPublic) { return createAccountPublic(vPublic).humanAccountPublic(); } @@ -122,22 +122,22 @@ public: std::string humanAccountPrivate() const; bool setAccountPrivate(const std::string& strPrivate); - void setAccountPrivate(const std::vector& vPrivate); + void setAccountPrivate(Blob const& vPrivate); void setAccountPrivate(uint256 hash256); void setAccountPrivate(const RippleAddress& naGenerator, const RippleAddress& naSeed, int seq); - bool accountPrivateSign(const uint256& uHash, std::vector& vucSig) const; - // bool accountPrivateVerify(const uint256& uHash, const std::vector& vucSig) const; + bool accountPrivateSign(const uint256& uHash, Blob & vucSig) const; + // bool accountPrivateVerify(const uint256& uHash, Blob const& vucSig) const; // Encrypt a message. - std::vector accountPrivateEncrypt(const RippleAddress& naPublicTo, const std::vector& vucPlainText) const; + Blob accountPrivateEncrypt(const RippleAddress& naPublicTo, Blob const& vucPlainText) const; // Decrypt a message. - std::vector accountPrivateDecrypt(const RippleAddress& naPublicFrom, const std::vector& vucCipherText) const; + Blob accountPrivateDecrypt(const RippleAddress& naPublicFrom, Blob const& vucCipherText) const; static RippleAddress createAccountPrivate(const RippleAddress& naGenerator, const RippleAddress& naSeed, int iSeq); - static RippleAddress createAccountPrivate(const std::vector& vPrivate) + static RippleAddress createAccountPrivate(Blob const& vPrivate) { RippleAddress naNew; @@ -146,7 +146,7 @@ public: return naNew; } - static std::string createHumanAccountPrivate(const std::vector& vPrivate) { + static std::string createHumanAccountPrivate(Blob const& vPrivate) { return createAccountPrivate(vPrivate).humanAccountPrivate(); } @@ -155,12 +155,12 @@ public: // Use to generate a master or regular family. // BIGNUM* getGeneratorBN() const; // DEPRECATED - const std::vector& getGenerator() const; + Blob const& getGenerator() const; std::string humanGenerator() const; bool setGenerator(const std::string& strGenerator); - void setGenerator(const std::vector& vPublic); + void setGenerator(Blob const& vPublic); // void setGenerator(const RippleAddress& seed); // Create generator for making public deterministic keys. diff --git a/modules/ripple_data/protocol/ripple_STAmount.cpp b/modules/ripple_data/protocol/ripple_STAmount.cpp index 0e65d4d096..e0a38f80c5 100644 --- a/modules/ripple_data/protocol/ripple_STAmount.cpp +++ b/modules/ripple_data/protocol/ripple_STAmount.cpp @@ -39,7 +39,7 @@ bool STAmount::currencyFromString(uint160& uDstCurrency, const std::string& sCur } else if (3 == sCurrency.size()) { - std::vector vucIso(3); + Blob vucIso(3); std::transform(sCurrency.begin(), sCurrency.end(), vucIso.begin(), ::toupper); @@ -216,10 +216,10 @@ std::string STAmount::createHumanCurrency(const uint160& uCurrency) SerializerIterator sit(s); - std::vector vucZeros = sit.getRaw(96/8); - std::vector vucIso = sit.getRaw(24/8); - std::vector vucVersion = sit.getRaw(16/8); - std::vector vucReserved = sit.getRaw(24/8); + Blob vucZeros = sit.getRaw(96/8); + Blob vucIso = sit.getRaw(24/8); + Blob vucVersion = sit.getRaw(16/8); + Blob vucReserved = sit.getRaw(24/8); bool bIso = ::isZero(vucZeros.begin(), vucZeros.size()) // Leading zeros && ::isZero(vucVersion.begin(), vucVersion.size()) // Zero version diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.cpp b/modules/ripple_data/protocol/ripple_SerializedObject.cpp index db5c984233..14e7ff32cc 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedObject.cpp @@ -599,12 +599,12 @@ uint160 STObject::getFieldAccount160(SField::ref field) const return a; } -std::vector STObject::getFieldVL(SField::ref field) const +Blob STObject::getFieldVL(SField::ref field) const { const SerializedType* rf = peekAtPField(field); if (!rf) throw std::runtime_error("Field not found"); SerializedTypeID id = rf->getSType(); - if (id == STI_NOTPRESENT) return std::vector(); // optional field not present + if (id == STI_NOTPRESENT) return Blob (); // optional field not present const STVariableLength *cf = dynamic_cast(rf); if (!cf) throw std::runtime_error("Wrong field type"); return cf->getValue(); @@ -739,7 +739,7 @@ void STObject::setFieldAccount(SField::ref field, const uint160& v) cf->setValueH160(v); } -void STObject::setFieldVL(SField::ref field, const std::vector& v) +void STObject::setFieldVL(SField::ref field, Blob const& v) { SerializedType* rf = getPField(field, true); if (!rf) throw std::runtime_error("Field not found"); @@ -1267,7 +1267,7 @@ BOOST_AUTO_TEST_CASE( FieldManipulation_test ) for (int i = 0; i < 1000; i++) { - std::vector j(i, 2); + Blob j(i, 2); object1.setFieldVL(sfTestVL, j); diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.h b/modules/ripple_data/protocol/ripple_SerializedObject.h index af7ee62782..9f2a89de81 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.h +++ b/modules/ripple_data/protocol/ripple_SerializedObject.h @@ -88,7 +88,7 @@ public: uint256 getFieldH256(SField::ref field) const; RippleAddress getFieldAccount(SField::ref field) const; uint160 getFieldAccount160(SField::ref field) const; - std::vector getFieldVL(SField::ref field) const; + Blob getFieldVL(SField::ref field) const; const STAmount& getFieldAmount(SField::ref field) const; const STPathSet& getFieldPathSet(SField::ref field) const; const STVector256& getFieldV256(SField::ref field) const; @@ -100,7 +100,7 @@ public: void setFieldH128(SField::ref field, const uint128&); void setFieldH160(SField::ref field, const uint160&); void setFieldH256(SField::ref field, const uint256&); - void setFieldVL(SField::ref field, const std::vector&); + void setFieldVL(SField::ref field, Blob const&); void setFieldAccount(SField::ref field, const uint160&); void setFieldAccount(SField::ref field, const RippleAddress& addr) { setFieldAccount(field, addr.getAccountID()); } diff --git a/modules/ripple_data/protocol/ripple_SerializedTypes.cpp b/modules/ripple_data/protocol/ripple_SerializedTypes.cpp index ca983f2b95..02511bd1c4 100644 --- a/modules/ripple_data/protocol/ripple_SerializedTypes.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedTypes.cpp @@ -269,8 +269,8 @@ STAccount* STAccount::construct(SerializerIterator& u, SField::ref name) // Return a new object from a SerializerIterator. STVector256* STVector256::construct(SerializerIterator& u, SField::ref name) { - std::vector data = u.getVL(); - std::vector::iterator begin = data.begin(); + Blob data = u.getVL(); + Blob ::iterator begin = data.begin(); UPTR_T vec(new STVector256(name)); @@ -283,7 +283,7 @@ STVector256* STVector256::construct(SerializerIterator& u, SField::ref name) unsigned int uEnd = uStart + (256 / 8); // This next line could be optimized to construct a default uint256 in the vector and then copy into it - vec->mValue.push_back(uint256(std::vector(begin + uStart, begin + uEnd))); + vec->mValue.push_back(uint256(Blob (begin + uStart, begin + uEnd))); uStart = uEnd; } diff --git a/modules/ripple_data/protocol/ripple_SerializedTypes.h b/modules/ripple_data/protocol/ripple_SerializedTypes.h index 525c9d1703..cbefc7e454 100644 --- a/modules/ripple_data/protocol/ripple_SerializedTypes.h +++ b/modules/ripple_data/protocol/ripple_SerializedTypes.h @@ -574,8 +574,8 @@ private: class STVariableLength : public SerializedType { public: - STVariableLength(const std::vector& v) : value(v) { ; } - STVariableLength(SField::ref n, const std::vector& v) : SerializedType(n), value(v) { ; } + STVariableLength(Blob const& v) : value(v) { ; } + STVariableLength(SField::ref n, Blob const& v) : SerializedType(n), value(v) { ; } STVariableLength(SField::ref n) : SerializedType(n) { ; } STVariableLength(SerializerIterator&, SField::ref name = sfGeneric); STVariableLength() { ; } @@ -586,17 +586,17 @@ public: virtual std::string getText() const; void add(Serializer& s) const { s.addVL(value); } - const std::vector& peekValue() const { return value; } - std::vector& peekValue() { return value; } - std::vector getValue() const { return value; } - void setValue(const std::vector& v) { value=v; } + Blob const& peekValue() const { return value; } + Blob & peekValue() { return value; } + Blob getValue() const { return value; } + void setValue(Blob const& v) { value=v; } - operator std::vector() const { return value; } + operator Blob () const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value.empty(); } private: - std::vector value; + Blob value; virtual STVariableLength* duplicate() const { return new STVariableLength(*this); } static STVariableLength* construct(SerializerIterator&, SField::ref); @@ -605,8 +605,8 @@ private: class STAccount : public STVariableLength { public: - STAccount(const std::vector& v) : STVariableLength(v) { ; } - STAccount(SField::ref n, const std::vector& v) : STVariableLength(n, v) { ; } + STAccount(Blob const& v) : STVariableLength(v) { ; } + STAccount(SField::ref n, Blob const& v) : STVariableLength(n, v) { ; } STAccount(SField::ref n, const uint160& v); STAccount(SField::ref n) : STVariableLength(n) { ; } STAccount() { ; } diff --git a/modules/ripple_data/protocol/ripple_Serializer.cpp b/modules/ripple_data/protocol/ripple_Serializer.cpp index 59d9de09d5..edf4e07bdc 100644 --- a/modules/ripple_data/protocol/ripple_Serializer.cpp +++ b/modules/ripple_data/protocol/ripple_Serializer.cpp @@ -64,7 +64,7 @@ int Serializer::add256(const uint256& i) return ret; } -int Serializer::addRaw(const std::vector &vector) +int Serializer::addRaw(Blob const& vector) { int ret = mData.size(); mData.insert(mData.end(), vector.begin(), vector.end()); @@ -239,16 +239,16 @@ int Serializer::removeLastByte() return ret; } -bool Serializer::getRaw(std::vector& o, int offset, int length) const +bool Serializer::getRaw(Blob & o, int offset, int length) const { if ((offset + length) > mData.size()) return false; o.assign(mData.begin() + offset, mData.begin() + offset + length); return true; } -std::vector Serializer::getRaw(int offset, int length) const +Blob Serializer::getRaw(int offset, int length) const { - std::vector o; + Blob o; if ((offset + length) > mData.size()) return o; o.assign(mData.begin() + offset, mData.begin() + offset + length); return o; @@ -275,7 +275,7 @@ uint256 Serializer::getSHA512Half(int size) const return getSHA512Half(mData, size); } -uint256 Serializer::getSHA512Half(const std::vector& data, int size) +uint256 Serializer::getSHA512Half(Blob const& data, int size) { uint256 j[2]; if ((size < 0) || (size > data.size())) size = data.size(); @@ -315,7 +315,7 @@ uint256 Serializer::getPrefixHash(uint32 prefix, const unsigned char *data, int bool Serializer::checkSignature(int pubkeyOffset, int signatureOffset) const { - std::vector pubkey, signature; + Blob pubkey, signature; if (!getRaw(pubkey, pubkeyOffset, 65)) return false; if (!getRaw(signature, signatureOffset, 72)) return false; @@ -324,26 +324,26 @@ bool Serializer::checkSignature(int pubkeyOffset, int signatureOffset) const return pubCKey.Verify(getSHA512Half(signatureOffset), signature); } -bool Serializer::checkSignature(const std::vector &signature, CKey& key) const +bool Serializer::checkSignature(Blob const& signature, CKey& key) const { return key.Verify(getSHA512Half(), signature); } -bool Serializer::makeSignature(std::vector &signature, CKey& key) const +bool Serializer::makeSignature(Blob &signature, CKey& key) const { return key.Sign(getSHA512Half(), signature); } bool Serializer::addSignature(CKey& key) { - std::vector signature; + Blob signature; if (!key.Sign(getSHA512Half(), signature)) return false; assert(signature.size() == 72); addRaw(signature); return true; } -int Serializer::addVL(const std::vector& vector) +int Serializer::addVL(Blob const& vector) { int ret = addRaw(encodeVL(vector.size())); addRaw(vector); @@ -367,7 +367,7 @@ int Serializer::addVL(const std::string& string) return ret; } -bool Serializer::getVL(std::vector& objectVL, int offset, int& length) const +bool Serializer::getVL(Blob & objectVL, int offset, int& length) const { int b1; if (!get8(b1, offset++)) return false; @@ -432,20 +432,20 @@ bool Serializer::getVLLength(int& length, int offset) const return true; } -std::vector Serializer::encodeVL(int length) +Blob Serializer::encodeVL(int length) { unsigned char lenBytes[4]; if (length <= 192) { lenBytes[0] = static_cast(length); - return std::vector(&lenBytes[0], &lenBytes[1]); + return Blob (&lenBytes[0], &lenBytes[1]); } else if (length <= 12480) { length -= 193; lenBytes[0] = 193 + static_cast(length >> 8); lenBytes[1] = static_cast(length & 0xff); - return std::vector(&lenBytes[0], &lenBytes[2]); + return Blob (&lenBytes[0], &lenBytes[2]); } else if (length <= 918744) { @@ -453,7 +453,7 @@ std::vector Serializer::encodeVL(int length) lenBytes[0] = 241 + static_cast(length >> 16); lenBytes[1] = static_cast((length >> 8) & 0xff); lenBytes[2] = static_cast(length & 0xff); - return std::vector(&lenBytes[0], &lenBytes[3]); + return Blob (&lenBytes[0], &lenBytes[3]); } else throw std::overflow_error("lenlen"); } @@ -574,16 +574,16 @@ uint256 SerializerIterator::get256() return val; } -std::vector SerializerIterator::getVL() +Blob SerializerIterator::getVL() { int length; - std::vector vl; + Blob vl; if (!mSerializer.getVL(vl, mPos, length)) throw std::runtime_error("invalid serializer getVL"); mPos += length; return vl; } -std::vector SerializerIterator::getRaw(int iLength) +Blob SerializerIterator::getRaw(int iLength) { int iPos = mPos; mPos += iLength; diff --git a/modules/ripple_data/protocol/ripple_Serializer.h b/modules/ripple_data/protocol/ripple_Serializer.h index c2a2f07c0e..fd14a21b9c 100644 --- a/modules/ripple_data/protocol/ripple_Serializer.h +++ b/modules/ripple_data/protocol/ripple_Serializer.h @@ -9,15 +9,15 @@ public: typedef boost::shared_ptr pointer; protected: - std::vector mData; + Blob mData; public: Serializer(int n = 256) { mData.reserve(n); } - Serializer(const std::vector &data) : mData(data) { ; } + Serializer(Blob const& data) : mData(data) { ; } Serializer(const std::string& data) : mData(data.data(), (data.data()) + data.size()) { ; } - Serializer(std::vector::iterator begin, std::vector::iterator end) : + Serializer(Blob ::iterator begin, Blob ::iterator end) : mData(begin, end) { ; } - Serializer(std::vector::const_iterator begin, std::vector::const_iterator end) : + Serializer(Blob ::const_iterator begin, Blob ::const_iterator end) : mData(begin, end) { ; } // assemble functions @@ -28,12 +28,12 @@ public: int add128(const uint128&); // private key generators int add160(const uint160&); // account names, hankos int add256(const uint256&); // transaction and ledger hashes - int addRaw(const std::vector &vector); + int addRaw(Blob const& vector); int addRaw(const void *ptr, int len); int addRaw(const Serializer& s); int addZeros(size_t uBytes); - int addVL(const std::vector &vector); + int addVL(Blob const& vector); int addVL(const std::string& string); int addVL(const void *ptr, int len); @@ -47,10 +47,10 @@ public: bool get160(uint160&, int offset) const; bool get256(uint256&, int offset) const; uint256 get256(int offset) const; - bool getRaw(std::vector&, int offset, int length) const; - std::vector getRaw(int offset, int length) const; + bool getRaw(Blob &, int offset, int length) const; + Blob getRaw(int offset, int length) const; - bool getVL(std::vector& objectVL, int offset, int& length) const; + bool getVL(Blob & objectVL, int offset, int& length) const; bool getVLLength(int& length, int offset) const; bool getFieldID(int& type, int& name, int offset) const; @@ -61,7 +61,7 @@ public: uint160 getRIPEMD160(int size=-1) const; uint256 getSHA256(int size=-1) const; uint256 getSHA512Half(int size=-1) const; - static uint256 getSHA512Half(const std::vector& data, int size=-1); + static uint256 getSHA512Half(Blob const& data, int size=-1); static uint256 getSHA512Half(const unsigned char *data, int len); static uint256 getSHA512Half(const std::string& strData); @@ -69,15 +69,15 @@ public: static uint256 getPrefixHash(uint32 prefix, const unsigned char *data, int len); uint256 getPrefixHash(uint32 prefix) const { return getPrefixHash(prefix, &(mData.front()), mData.size()); } - static uint256 getPrefixHash(uint32 prefix, const std::vector& data) + static uint256 getPrefixHash(uint32 prefix, Blob const& data) { return getPrefixHash(prefix, &(data.front()), data.size()); } static uint256 getPrefixHash(uint32 prefix, const std::string& strData) { return getPrefixHash(prefix, reinterpret_cast(strData.data()), strData.size()); } // totality functions - const std::vector& peekData() const { return mData; } - std::vector getData() const { return mData; } - std::vector& modData() { return mData; } + Blob const& peekData() const { return mData; } + Blob getData() const { return mData; } + Blob & modData() { return mData; } int getCapacity() const { return mData.capacity(); } int getDataLength() const { return mData.size(); } const void* getDataPtr() const { return &mData.front(); } @@ -90,28 +90,28 @@ public: bool chop(int num); // vector-like functions - std::vector::iterator begin() { return mData.begin(); } - std::vector::iterator end() { return mData.end(); } - std::vector::const_iterator begin() const { return mData.begin(); } - std::vector::const_iterator end() const { return mData.end(); } - std::vector::size_type size() const { return mData.size(); } + Blob ::iterator begin() { return mData.begin(); } + Blob ::iterator end() { return mData.end(); } + Blob ::const_iterator begin() const { return mData.begin(); } + Blob ::const_iterator end() const { return mData.end(); } + Blob ::size_type size() const { return mData.size(); } void reserve(size_t n) { mData.reserve(n); } void resize(size_t n) { mData.resize(n); } size_t capacity() const { return mData.capacity(); } - bool operator==(const std::vector& v) { return v == mData; } - bool operator!=(const std::vector& v) { return v != mData; } + bool operator==(Blob const& v) { return v == mData; } + bool operator!=(Blob const& v) { return v != mData; } bool operator==(const Serializer& v) { return v.mData == mData; } bool operator!=(const Serializer& v) { return v.mData != mData; } // signature functions bool checkSignature(int pubkeyOffset, int signatureOffset) const; - bool checkSignature(const std::vector& signature, CKey& rkey) const; - bool makeSignature(std::vector& signature, CKey& rkey) const; + bool checkSignature(Blob const& signature, CKey& rkey) const; + bool makeSignature(Blob & signature, CKey& rkey) const; bool addSignature(CKey& rkey); // low-level VL length encode/decode functions - static std::vector encodeVL(int length); + static Blob encodeVL(int length); static int lengthVL(int length) { return length + encodeLengthLength(length); } static int encodeLengthLength(int length); // length to encode length static int decodeLengthLength(int b1); @@ -152,9 +152,9 @@ public: void getFieldID(int& type, int& field); - std::vector getRaw(int iLength); + Blob getRaw(int iLength); - std::vector getVL(); + Blob getVL(); }; #endif diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 696ff93656..a53275dda0 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -1289,6 +1289,7 @@ + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index 1cd8913c6b..6d662f6107 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -1526,6 +1526,9 @@ 1. Modules\ripple_data\protocol + + 1. Modules\ripple_basics\types + diff --git a/src/cpp/database/SqliteDatabase.cpp b/src/cpp/database/SqliteDatabase.cpp index e341c053bb..e8e7f8e973 100644 --- a/src/cpp/database/SqliteDatabase.cpp +++ b/src/cpp/database/SqliteDatabase.cpp @@ -207,11 +207,11 @@ int SqliteDatabase::getBinary(int colIndex,unsigned char* buf,int maxSize) return(size); } -std::vector SqliteDatabase::getBinary(int colIndex) +Blob SqliteDatabase::getBinary(int colIndex) { const unsigned char* blob = reinterpret_cast(sqlite3_column_blob(mCurrentStmt, colIndex)); size_t iSize = sqlite3_column_bytes(mCurrentStmt, colIndex); - std::vector vucResult; + Blob vucResult; vucResult.resize(iSize); std::copy(blob, blob+iSize, vucResult.begin()); @@ -324,7 +324,7 @@ int SqliteStatement::bindStatic(int position, const void *data, int length) return sqlite3_bind_blob(statement, position, data, length, SQLITE_STATIC); } -int SqliteStatement::bindStatic(int position, const std::vector& value) +int SqliteStatement::bindStatic(int position, Blob const& value) { return sqlite3_bind_blob(statement, position, &value.front(), value.size(), SQLITE_STATIC); } @@ -359,10 +359,10 @@ const void* SqliteStatement::peekBlob(int column) return sqlite3_column_blob(statement, column); } -std::vector SqliteStatement::getBlob(int column) +Blob SqliteStatement::getBlob(int column) { int size = sqlite3_column_bytes(statement, column); - std::vector ret(size); + Blob ret(size); memcpy(&(ret.front()), sqlite3_column_blob(statement, column), size); return ret; } diff --git a/src/cpp/database/SqliteDatabase.h b/src/cpp/database/SqliteDatabase.h index fb8305fcc4..b7396b43f2 100644 --- a/src/cpp/database/SqliteDatabase.h +++ b/src/cpp/database/SqliteDatabase.h @@ -52,7 +52,7 @@ public: bool getBool(int colIndex); // returns amount stored in buf int getBinary(int colIndex,unsigned char* buf,int maxSize); - std::vector getBinary(int colIndex); + Blob getBinary(int colIndex); uint64 getBigInt(int colIndex); sqlite3* peekConnection() { return mConnection; } @@ -86,7 +86,7 @@ public: // positions start at 1 int bind(int position, const void *data, int length); int bindStatic(int position, const void *data, int length); - int bindStatic(int position, const std::vector& value); + int bindStatic(int position, Blob const& value); int bind(int position, const std::string& value); int bindStatic(int position, const std::string& value); @@ -98,7 +98,7 @@ public: int size(int column); const void* peekBlob(int column); - std::vector getBlob(int column); + Blob getBlob(int column); std::string getString(int column); const char* peekString(int column); diff --git a/src/cpp/database/database.cpp b/src/cpp/database/database.cpp index 7958814e5e..6d882d7130 100644 --- a/src/cpp/database/database.cpp +++ b/src/cpp/database/database.cpp @@ -86,7 +86,7 @@ int Database::getBinary(const char* colName,unsigned char* buf,int maxSize) return(0); } -std::vector Database::getBinary(const std::string& strColName) +Blob Database::getBinary(const std::string& strColName) { int index; @@ -95,7 +95,7 @@ std::vector Database::getBinary(const std::string& strColName) return getBinary(index); } - return std::vector(); + return Blob (); } std::string Database::getStrBinary(const std::string& strColName) diff --git a/src/cpp/database/database.h b/src/cpp/database/database.h index 32c9b3b16c..9a63e56356 100644 --- a/src/cpp/database/database.h +++ b/src/cpp/database/database.h @@ -68,7 +68,7 @@ public: // returns amount stored in buf int getBinary(const char* colName, unsigned char* buf, int maxSize); - std::vector getBinary(const std::string& strColName); + Blob getBinary(const std::string& strColName); uint64 getBigInt(const char* colName); @@ -79,7 +79,7 @@ public: virtual bool getBool(int colIndex)=0; virtual int getBinary(int colIndex,unsigned char* buf,int maxSize)=0; virtual uint64 getBigInt(int colIndex)=0; - virtual std::vector getBinary(int colIndex)=0; + virtual Blob getBinary(int colIndex)=0; // int getSingleDBValueInt(const char* sql); // float getSingleDBValueFloat(const char* sql); diff --git a/src/cpp/ripple/AcceptedLedger.h b/src/cpp/ripple/AcceptedLedger.h index 45574d83eb..1298f9efc4 100644 --- a/src/cpp/ripple/AcceptedLedger.h +++ b/src/cpp/ripple/AcceptedLedger.h @@ -47,7 +47,7 @@ private: TransactionMetaSet::pointer mMeta; TER mResult; std::vector mAffected; - std::vector mRawMeta; + Blob mRawMeta; Json::Value mJson; void buildJson(); diff --git a/src/cpp/ripple/AccountItems.h b/src/cpp/ripple/AccountItems.h index fd06252bed..fef8800bb8 100644 --- a/src/cpp/ripple/AccountItems.h +++ b/src/cpp/ripple/AccountItems.h @@ -24,7 +24,7 @@ public: const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; } SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; } - std::vector getRaw() const; + Blob getRaw() const; // VFALCO TODO make an accessor for mLedgerEntry so we can change protected to private protected: diff --git a/src/cpp/ripple/AccountSetTransactor.cpp b/src/cpp/ripple/AccountSetTransactor.cpp index fbb2b46e91..2e7e168851 100644 --- a/src/cpp/ripple/AccountSetTransactor.cpp +++ b/src/cpp/ripple/AccountSetTransactor.cpp @@ -148,7 +148,7 @@ TER AccountSetTransactor::doApply() if (mTxn.isFieldPresent(sfMessageKey)) { - std::vector vucPublic = mTxn.getFieldVL(sfMessageKey); + Blob vucPublic = mTxn.getFieldVL(sfMessageKey); if (vucPublic.size() > PUBLIC_BYTES_MAX) { @@ -170,7 +170,7 @@ TER AccountSetTransactor::doApply() if (mTxn.isFieldPresent(sfDomain)) { - std::vector vucDomain = mTxn.getFieldVL(sfDomain); + Blob vucDomain = mTxn.getFieldVL(sfDomain); if (vucDomain.empty()) { diff --git a/src/cpp/ripple/AccountState.cpp b/src/cpp/ripple/AccountState.cpp index e10b30b010..3eff3b7652 100644 --- a/src/cpp/ripple/AccountState.cpp +++ b/src/cpp/ripple/AccountState.cpp @@ -22,7 +22,7 @@ AccountState::AccountState(SLE::ref ledgerEntry, const RippleAddress& naAccountI std::string AccountState::createGravatarUrl(uint128 uEmailHash) { - std::vector vucMD5(uEmailHash.begin(), uEmailHash.end()); + Blob vucMD5(uEmailHash.begin(), uEmailHash.end()); std::string strMD5Lower = strHex(vucMD5); boost::to_lower(strMD5Lower); diff --git a/src/cpp/ripple/AccountState.h b/src/cpp/ripple/AccountState.h index 47e52a14eb..0c412cb865 100644 --- a/src/cpp/ripple/AccountState.h +++ b/src/cpp/ripple/AccountState.h @@ -44,7 +44,7 @@ public: const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; } SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; } - std::vector getRaw() const; + Blob getRaw() const; void addJson(Json::Value& value); void dump(); diff --git a/src/cpp/ripple/Application.h b/src/cpp/ripple/Application.h index 4c95d1f979..a11644f62e 100644 --- a/src/cpp/ripple/Application.h +++ b/src/cpp/ripple/Application.h @@ -34,7 +34,7 @@ class IPeers; class RPCDoor; class PeerDoor; -typedef TaggedCache , UptimeTimerAdapter> NodeCache; +typedef TaggedCache NodeCache; typedef TaggedCache SLECache; class Application diff --git a/src/cpp/ripple/Interpreter.cpp b/src/cpp/ripple/Interpreter.cpp index bd2ba21003..d9740dc1e9 100644 --- a/src/cpp/ripple/Interpreter.cpp +++ b/src/cpp/ripple/Interpreter.cpp @@ -111,7 +111,7 @@ bool Interpreter::endBlock() return(true); } -TER Interpreter::interpret(Contract* contract,const SerializedTransaction& txn,std::vector& code) +TER Interpreter::interpret(Contract* contract,const SerializedTransaction& txn,Blob & code) { mContract=contract; mCode=&code; diff --git a/src/cpp/ripple/Interpreter.h b/src/cpp/ripple/Interpreter.h index f23660986d..f97f4ae8b6 100644 --- a/src/cpp/ripple/Interpreter.h +++ b/src/cpp/ripple/Interpreter.h @@ -13,7 +13,7 @@ class Interpreter std::vector mStack; Contract* mContract; - std::vector* mCode; + Blob * mCode; unsigned int mInstructionPointer; int mTotalFee; @@ -44,7 +44,7 @@ public: Interpreter(); // returns a TransactionEngineResult - TER interpret(Contract* contract,const SerializedTransaction& txn,std::vector& code); + TER interpret(Contract* contract,const SerializedTransaction& txn,Blob & code); void stop(); diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index 12e69e981a..95339bc958 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -90,7 +90,7 @@ Ledger::Ledger(bool /* dummy */, Ledger& prevLedger) : zeroFees(); } -Ledger::Ledger(const std::vector& rawLedger, bool hasPrefix) : +Ledger::Ledger(Blob const& rawLedger, bool hasPrefix) : mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true) { Serializer s(rawLedger); @@ -272,7 +272,7 @@ Transaction::pointer Ledger::getTransaction(const uint256& transID) const txn = Transaction::sharedTransaction(item->getData(), true); else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { - std::vector txnData; + Blob txnData; int txnLength; if (!item->peekSerializer().getVL(txnData, 0, txnLength)) return Transaction::pointer(); diff --git a/src/cpp/ripple/Ledger.h b/src/cpp/ripple/Ledger.h index cddbbc80cb..05ebf2a49f 100644 --- a/src/cpp/ripple/Ledger.h +++ b/src/cpp/ripple/Ledger.h @@ -76,7 +76,7 @@ public: uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution, uint32 ledgerSeq, bool& loaded); // used for database ledgers - Ledger(const std::vector& rawLedger, bool hasPrefix); + Ledger(Blob const& rawLedger, bool hasPrefix); Ledger(const std::string& rawLedger, bool hasPrefix); Ledger(bool dummy, Ledger& previous); // ledger after this one diff --git a/src/cpp/ripple/LedgerAcquire.cpp b/src/cpp/ripple/LedgerAcquire.cpp index 2043962577..a3f6f659c1 100644 --- a/src/cpp/ripple/LedgerAcquire.cpp +++ b/src/cpp/ripple/LedgerAcquire.cpp @@ -116,7 +116,7 @@ bool LedgerAcquire::tryLocal() HashedObject::pointer node = theApp->getHashedObjectStore().retrieve(mHash); if (!node) { - std::vector data; + Blob data; if (!theApp->getOPs().getFetchPack(mHash, data)) return false; WriteLog (lsTRACE, LedgerAcquire) << "Ledger base found in fetch pack"; @@ -672,7 +672,7 @@ bool LedgerAcquire::takeBase(const std::string& data) // data must not have hash } bool LedgerAcquire::takeTxNode(const std::list& nodeIDs, - const std::list< std::vector >& data, SMAddNode& san) + const std::list< Blob >& data, SMAddNode& san) { boost::recursive_mutex::scoped_lock sl(mLock); if (!mHaveBase) @@ -681,7 +681,7 @@ bool LedgerAcquire::takeTxNode(const std::list& nodeIDs, return true; std::list::const_iterator nodeIDit = nodeIDs.begin(); - std::list< std::vector >::const_iterator nodeDatait = data.begin(); + std::list< Blob >::const_iterator nodeDatait = data.begin(); TransactionStateSF tFilter(mLedger->getLedgerSeq()); while (nodeIDit != nodeIDs.end()) { @@ -713,7 +713,7 @@ bool LedgerAcquire::takeTxNode(const std::list& nodeIDs, } bool LedgerAcquire::takeAsNode(const std::list& nodeIDs, - const std::list< std::vector >& data, SMAddNode& san) + const std::list< Blob >& data, SMAddNode& san) { WriteLog (lsTRACE, LedgerAcquire) << "got ASdata (" << nodeIDs.size() <<") acquiring ledger " << mHash; CondLog (nodeIDs.size() == 1, lsTRACE, LedgerAcquire) << "got AS node: " << nodeIDs.front(); @@ -728,7 +728,7 @@ bool LedgerAcquire::takeAsNode(const std::list& nodeIDs, return true; std::list::const_iterator nodeIDit = nodeIDs.begin(); - std::list< std::vector >::const_iterator nodeDatait = data.begin(); + std::list< Blob >::const_iterator nodeDatait = data.begin(); AccountStateSF tFilter(mLedger->getLedgerSeq()); while (nodeIDit != nodeIDs.end()) { @@ -762,7 +762,7 @@ bool LedgerAcquire::takeAsNode(const std::list& nodeIDs, return true; } -bool LedgerAcquire::takeAsRootNode(const std::vector& data, SMAddNode& san) +bool LedgerAcquire::takeAsRootNode(Blob const& data, SMAddNode& san) { boost::recursive_mutex::scoped_lock sl(mLock); if (mFailed || mHaveState) @@ -774,7 +774,7 @@ bool LedgerAcquire::takeAsRootNode(const std::vector& data, SMAdd mLedger->peekAccountStateMap()->addRootNode(mLedger->getAccountHash(), data, snfWIRE, &tFilter)); } -bool LedgerAcquire::takeTxRootNode(const std::vector& data, SMAddNode& san) +bool LedgerAcquire::takeTxRootNode(Blob const& data, SMAddNode& san) { boost::recursive_mutex::scoped_lock sl(mLock); if (mFailed || mHaveState) @@ -964,7 +964,7 @@ void LedgerAcquireMaster::gotLedgerData(Job&, uint256 hash, if ((packet.type() == ripple::liTX_NODE) || (packet.type() == ripple::liAS_NODE)) { std::list nodeIDs; - std::list< std::vector > nodeData; + std::list< Blob > nodeData; if (packet.nodes().size() <= 0) { @@ -983,7 +983,7 @@ void LedgerAcquireMaster::gotLedgerData(Job&, uint256 hash, } nodeIDs.push_back(SHAMapNode(node.nodeid().data(), node.nodeid().size())); - nodeData.push_back(std::vector(node.nodedata().begin(), node.nodedata().end())); + nodeData.push_back(Blob (node.nodedata().begin(), node.nodedata().end())); } SMAddNode ret; if (packet.type() == ripple::liTX_NODE) diff --git a/src/cpp/ripple/LedgerAcquire.h b/src/cpp/ripple/LedgerAcquire.h index df2470fa63..831da03cb5 100644 --- a/src/cpp/ripple/LedgerAcquire.h +++ b/src/cpp/ripple/LedgerAcquire.h @@ -115,12 +115,12 @@ public: bool addOnComplete(FUNCTION_TYPE); bool takeBase(const std::string& data); - bool takeTxNode(const std::list& IDs, const std::list >& data, + bool takeTxNode(const std::list& IDs, const std::list& data, SMAddNode&); - bool takeTxRootNode(const std::vector& data, SMAddNode&); - bool takeAsNode(const std::list& IDs, const std::list >& data, + bool takeTxRootNode(Blob const& data, SMAddNode&); + bool takeAsNode(const std::list& IDs, const std::list& data, SMAddNode&); - bool takeAsRootNode(const std::vector& data, SMAddNode&); + bool takeAsRootNode(Blob const& data, SMAddNode&); void trigger(Peer::ref); bool tryLocal(); void addPeers(); diff --git a/src/cpp/ripple/LedgerConsensus.cpp b/src/cpp/ripple/LedgerConsensus.cpp index 9ae280c26e..f9c9e16293 100644 --- a/src/cpp/ripple/LedgerConsensus.cpp +++ b/src/cpp/ripple/LedgerConsensus.cpp @@ -190,7 +190,7 @@ void LedgerConsensus::checkOurValidation() v->sign(signingHash, mValPrivate); theApp->getHashRouter ().addSuppression (signingHash); theApp->getValidations().addValidation(v, "localMissing"); - std::vector validation = v->getSigned(); + Blob validation = v->getSigned(); ripple::TMValidation val; val.set_validation(&validation[0], validation.size()); #if 0 @@ -824,15 +824,15 @@ void LedgerConsensus::propose() prop.set_proposeseq(mOurPosition->getProposeSeq()); prop.set_closetime(mOurPosition->getCloseTime()); - std::vector pubKey = mOurPosition->getPubKey(); - std::vector sig = mOurPosition->sign(); + Blob pubKey = mOurPosition->getPubKey(); + Blob sig = mOurPosition->sign(); prop.set_nodepubkey(&pubKey[0], pubKey.size()); prop.set_signature(&sig[0], sig.size()); theApp->getPeers().relayMessage(NULL, boost::make_shared(prop, ripple::mtPROPOSE_LEDGER)); } -void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vector& tx) +void LedgerConsensus::addDisputedTransaction(const uint256& txID, Blob const& tx) { if (mDisputes.find(txID) != mDisputes.end()) return; @@ -945,7 +945,7 @@ bool LedgerConsensus::peerHasSet(Peer::ref peer, const uint256& hashSet, ripple: } SMAddNode LedgerConsensus::peerGaveNodes(Peer::ref peer, const uint256& setHash, - const std::list& nodeIDs, const std::list< std::vector >& nodeData) + const std::list& nodeIDs, const std::list< Blob >& nodeData) { boost::unordered_map::iterator acq = mAcquiring.find(setHash); if (acq == mAcquiring.end()) @@ -1227,7 +1227,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer) theApp->getHashRouter ().addSuppression (signingHash); // suppress it if we receive it theApp->getValidations().addValidation(v, "local"); theApp->getOPs().setLastValidation(v); - std::vector validation = v->getSigned(); + Blob validation = v->getSigned(); ripple::TMValidation val; val.set_validation(&validation[0], validation.size()); int j = theApp->getPeers().relayMessage(NULL, diff --git a/src/cpp/ripple/LedgerConsensus.h b/src/cpp/ripple/LedgerConsensus.h index a6686766ea..514fbc642c 100644 --- a/src/cpp/ripple/LedgerConsensus.h +++ b/src/cpp/ripple/LedgerConsensus.h @@ -33,7 +33,7 @@ public: SHAMap::ref getMap() { return mMap; } SMAddNode takeNodes(const std::list& IDs, - const std::list< std::vector >& data, Peer::ref); + const std::list< Blob >& data, Peer::ref); private: SHAMap::pointer mMap; @@ -53,7 +53,7 @@ class LCTransaction public: typedef boost::shared_ptr pointer; - LCTransaction(const uint256 &txID, const std::vector& tx, bool ourVote) : + LCTransaction(const uint256 &txID, Blob const& tx, bool ourVote) : mTransactionID(txID), mYays(0), mNays(0), mOurVote(ourVote), transaction(tx) { ; } const uint256& getTransactionID() const { return mTransactionID; } @@ -117,7 +117,7 @@ public: bool peerHasSet(Peer::ref peer, const uint256& set, ripple::TxSetStatus status); SMAddNode peerGaveNodes(Peer::ref peer, const uint256& setHash, - const std::list& nodeIDs, const std::list< std::vector >& nodeData); + const std::list& nodeIDs, const std::list< Blob >& nodeData); bool isOurPubKey(const RippleAddress &k) { return k == mValPublic; } @@ -133,7 +133,7 @@ private: SHAMap::pointer find(const uint256& hash); void createDisputes(SHAMap::ref, SHAMap::ref); - void addDisputedTransaction(const uint256&, const std::vector& transaction); + void addDisputedTransaction(const uint256&, Blob const& transaction); void adjustCount(SHAMap::ref map, const std::vector& peers); void propose(); diff --git a/src/cpp/ripple/LedgerProposal.cpp b/src/cpp/ripple/LedgerProposal.cpp index c3fc7dbedc..3a29a900e0 100644 --- a/src/cpp/ripple/LedgerProposal.cpp +++ b/src/cpp/ripple/LedgerProposal.cpp @@ -66,9 +66,9 @@ void LedgerProposal::bowOut() mProposeSeq = seqLeave; } -std::vector LedgerProposal::sign(void) +Blob LedgerProposal::sign(void) { - std::vector ret; + Blob ret; mPrivateKey.signNodePrivate(getSigningHash(), ret); // XXX If this can fail, find out sooner. diff --git a/src/cpp/ripple/LedgerProposal.h b/src/cpp/ripple/LedgerProposal.h index 7c4387da05..0d15d5e8ff 100644 --- a/src/cpp/ripple/LedgerProposal.h +++ b/src/cpp/ripple/LedgerProposal.h @@ -40,8 +40,8 @@ public: uint32 getProposeSeq() const { return mProposeSeq; } uint32 getCloseTime() const { return mCloseTime; } const RippleAddress& peekPublic() const { return mPublicKey; } - std::vector getPubKey() const { return mPublicKey.getNodePublic(); } - std::vector sign(); + Blob getPubKey() const { return mPublicKey.getNodePublic(); } + Blob sign(); void setPrevLedger(const uint256& prevLedger) { mPreviousLedger = prevLedger; } void setSignature(const std::string& signature) { mSignature = signature; } diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 0cb338053b..75c6d1f8cb 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -958,7 +958,7 @@ void NetworkOPs::takePosition(int seq, SHAMap::ref position) } SMAddNode NetworkOPs::gotTXData(const boost::shared_ptr& peer, const uint256& hash, - const std::list& nodeIDs, const std::list< std::vector >& nodeData) + const std::list& nodeIDs, const std::list< Blob >& nodeData) { if (!haveConsensusObject()) { @@ -1164,7 +1164,7 @@ std::vector NetworkOPs::getAccountTxsB( SQL_FOREACH(db, sql) { int txnSize = 2048; - std::vector rawTxn(txnSize); + Blob rawTxn(txnSize); txnSize = db->getBinary("RawTxn", &rawTxn[0], rawTxn.size()); if (txnSize > rawTxn.size()) { @@ -1175,7 +1175,7 @@ std::vector NetworkOPs::getAccountTxsB( rawTxn.resize(txnSize); int metaSize = 2048; - std::vector rawMeta(metaSize); + Blob rawMeta(metaSize); metaSize = db->getBinary("TxnMeta", &rawMeta[0], rawMeta.size()); if (metaSize > rawMeta.size()) { @@ -2095,12 +2095,12 @@ void NetworkOPs::sweepFetchPack() mFetchPack.sweep(); } -void NetworkOPs::addFetchPack(const uint256& hash, boost::shared_ptr< std::vector >& data) +void NetworkOPs::addFetchPack(const uint256& hash, boost::shared_ptr< Blob >& data) { mFetchPack.canonicalize(hash, data, false); } -bool NetworkOPs::getFetchPack(const uint256& hash, std::vector& data) +bool NetworkOPs::getFetchPack(const uint256& hash, Blob & data) { bool ret = mFetchPack.retrieve(hash, data); if (!ret) diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index c6009cec3d..ea4031052e 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -210,22 +210,22 @@ public: Json::Value& jvResult); // raw object operations - bool findRawLedger(const uint256& ledgerHash, std::vector& rawLedger); - bool findRawTransaction(const uint256& transactionHash, std::vector& rawTransaction); - bool findAccountNode(const uint256& nodeHash, std::vector& rawAccountNode); - bool findTransactionNode(const uint256& nodeHash, std::vector& rawTransactionNode); + bool findRawLedger(const uint256& ledgerHash, Blob & rawLedger); + bool findRawTransaction(const uint256& transactionHash, Blob & rawTransaction); + bool findAccountNode(const uint256& nodeHash, Blob & rawAccountNode); + bool findTransactionNode(const uint256& nodeHash, Blob & rawTransactionNode); // tree synchronization operations bool getTransactionTreeNodes(uint32 ledgerSeq, const uint256& myNodeID, - const std::vector& myNode, std::list< std::vector >& newNodes); + Blob const& myNode, std::list< Blob >& newNodes); bool getAccountStateNodes(uint32 ledgerSeq, const uint256& myNodeId, - const std::vector& myNode, std::list< std::vector >& newNodes); + Blob const& myNode, std::list< Blob >& newNodes); // ledger proposal/close functions void processTrustedProposal(LedgerProposal::pointer proposal, boost::shared_ptr set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood); SMAddNode gotTXData(const boost::shared_ptr& peer, const uint256& hash, - const std::list& nodeIDs, const std::list< std::vector >& nodeData); + const std::list& nodeIDs, const std::list< Blob >& nodeData); bool recvValidation(SerializedValidation::ref val, const std::string& source); void takePosition(int seq, SHAMap::ref position); SHAMap::pointer getTXMap(const uint256& hash); @@ -236,8 +236,8 @@ public: Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime); bool shouldFetchPack(uint32 seq); void gotFetchPack(bool progress, uint32 seq); - void addFetchPack(const uint256& hash, boost::shared_ptr< std::vector >& data); - bool getFetchPack(const uint256& hash, std::vector& data); + void addFetchPack(const uint256& hash, boost::shared_ptr< Blob >& data); + bool getFetchPack(const uint256& hash, Blob & data); int getFetchSize(); void sweepFetchPack(); @@ -368,7 +368,7 @@ private: subMapType mSubTransactions; // all accepted transactions subMapType mSubRTTransactions; // all proposed and accepted transactions - TaggedCache< uint256, std::vector, UptimeTimerAdapter > mFetchPack; + TaggedCache< uint256, Blob , UptimeTimerAdapter > mFetchPack; uint32 mLastFetchPack; uint32 mFetchSeq; diff --git a/src/cpp/ripple/NicknameState.h b/src/cpp/ripple/NicknameState.h index ec0b4738e8..31144e8bcc 100644 --- a/src/cpp/ripple/NicknameState.h +++ b/src/cpp/ripple/NicknameState.h @@ -25,7 +25,7 @@ public: const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; } SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; } - std::vector getRaw() const; + Blob getRaw() const; void addJson(Json::Value& value); }; diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 3d987a2808..ceabea0ec3 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -389,8 +389,8 @@ Json::Value RPCHandler::getMasterGenerator(Ledger::ref lrLedger, const RippleAdd return rpcError(rpcNO_ACCOUNT); } - std::vector vucCipher = sleGen->getFieldVL(sfGenerator); - std::vector vucMasterGenerator = na0Private.accountPrivateDecrypt(na0Public, vucCipher); + Blob vucCipher = sleGen->getFieldVL(sfGenerator); + Blob vucMasterGenerator = na0Private.accountPrivateDecrypt(na0Public, vucCipher); if (vucMasterGenerator.empty()) { return rpcError(rpcFAIL_GEN_DECRPYT); @@ -543,8 +543,8 @@ Json::Value RPCHandler::accountFromString(Ledger::ref lrLedger, RippleAddress& n else { // Found master public key. - std::vector vucCipher = sleGen->getFieldVL(sfGenerator); - std::vector vucMasterGenerator = naRegular0Private.accountPrivateDecrypt(naRegular0Public, vucCipher); + Blob vucCipher = sleGen->getFieldVL(sfGenerator); + Blob vucMasterGenerator = naRegular0Private.accountPrivateDecrypt(naRegular0Public, vucCipher); if (vucMasterGenerator.empty()) { rpcError(rpcNO_GEN_DECRPYT); @@ -1590,7 +1590,7 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest, int& cost, ScopedLock& M Json::Value jvResult; - std::vector vucBlob(strUnHex(jvRequest["tx_blob"].asString())); + Blob vucBlob(strUnHex(jvRequest["tx_blob"].asString())); if (!vucBlob.size()) { diff --git a/src/cpp/ripple/RPCServer.h b/src/cpp/ripple/RPCServer.h index 66b24c5ccc..8a0c4c2e2c 100644 --- a/src/cpp/ripple/RPCServer.h +++ b/src/cpp/ripple/RPCServer.h @@ -25,7 +25,7 @@ private: boost::asio::ip::tcp::socket mSocket; boost::asio::streambuf mLineBuffer; - std::vector mQueryVec; + Blob mQueryVec; std::string mReplyStr; HTTPRequest mHTTPRequest; diff --git a/src/cpp/ripple/RippleState.h b/src/cpp/ripple/RippleState.h index bdc30ce3b5..ca70ffd6bb 100644 --- a/src/cpp/ripple/RippleState.h +++ b/src/cpp/ripple/RippleState.h @@ -64,7 +64,7 @@ public: SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; } Json::Value getJson(int); - std::vector getRaw() const; + Blob getRaw() const; }; #endif // vim:ts=4 diff --git a/src/cpp/ripple/SHAMap.cpp b/src/cpp/ripple/SHAMap.cpp index c7d517fca7..3ebffb6d2c 100644 --- a/src/cpp/ripple/SHAMap.cpp +++ b/src/cpp/ripple/SHAMap.cpp @@ -230,7 +230,7 @@ SHAMapTreeNode* SHAMap::getNodePointer(const SHAMapNode& id, const uint256& hash { if (filter) { - std::vector nodeData; + Blob nodeData; if (filter->haveNode(id, hash, nodeData)) { SHAMapTreeNode::pointer node = boost::make_shared( @@ -270,7 +270,7 @@ void SHAMap::trackNewNode(SHAMapTreeNode::pointer& node) (*mDirtyNodes)[*node] = node; } -SHAMapItem::SHAMapItem(const uint256& tag, const std::vector& data) +SHAMapItem::SHAMapItem(const uint256& tag, Blob const& data) : mTag(tag), mData(data) { ; } @@ -773,7 +773,7 @@ void SHAMap::fetchRoot(const uint256& hash, SHAMapSyncFilter* filter) } catch (SHAMapMissingNode&) { - std::vector nodeData; + Blob nodeData; if (!filter || !filter->haveNode(SHAMapNode(), hash, nodeData)) throw; root = boost::make_shared(SHAMapNode(), nodeData, @@ -850,7 +850,7 @@ SHAMapTreeNode::pointer SHAMap::getNode(const SHAMapNode& nodeID) return node; } -bool SHAMap::getPath(const uint256& index, std::vector< std::vector >& nodes, SHANodeFormat format) +bool SHAMap::getPath(const uint256& index, std::vector< Blob >& nodes, SHANodeFormat format) { // Return the path of nodes to the specified index in the specified format // Return value: true = node present, false = node not present @@ -912,9 +912,9 @@ void SHAMap::dump(bool hash) } -static std::vectorIntToVUC(int v) +static Blob IntToVUC(int v) { - std::vector vuc; + Blob vuc; for (int i = 0; i < 32; ++i) vuc.push_back(static_cast(v)); return vuc; diff --git a/src/cpp/ripple/SHAMap.h b/src/cpp/ripple/SHAMap.h index 41bd10dcf2..8fc159d80f 100644 --- a/src/cpp/ripple/SHAMap.h +++ b/src/cpp/ripple/SHAMap.h @@ -93,17 +93,17 @@ private: public: SHAMapItem(const uint256& tag) : mTag(tag) { ; } - SHAMapItem(const uint256& tag, const std::vector& data); + SHAMapItem(const uint256& tag, Blob const& data); SHAMapItem(const uint256& tag, const Serializer& s); - SHAMapItem(const std::vector& data); // tag by hash + SHAMapItem(Blob const& data); // tag by hash const uint256& getTag() const { return mTag; } - std::vector getData() const { return mData.getData(); } - const std::vector& peekData() const { return mData.peekData(); } + Blob getData() const { return mData.getData(); } + Blob const& peekData() const { return mData.peekData(); } Serializer& peekSerializer() { return mData; } - void addRaw(std::vector& s) const { s.insert(s.end(), mData.begin(), mData.end()); } + void addRaw(Blob & s) const { s.insert(s.end(), mData.begin(), mData.end()); } - void updateData(const std::vector& data) { mData=data; } + void updateData(Blob const& data) { mData=data; } bool operator==(const SHAMapItem& i) const { return mTag == i.mTag; } bool operator!=(const SHAMapItem& i) const { return mTag != i.mTag; } @@ -175,7 +175,7 @@ public: SHAMapTreeNode(const SHAMapNode& nodeID, SHAMapItem::ref item, TNType type, uint32 seq); // raw node functions - SHAMapTreeNode(const SHAMapNode& id, const std::vector& data, uint32 seq, + SHAMapTreeNode(const SHAMapNode& id, Blob const& data, uint32 seq, SHANodeFormat format, const uint256& hash, bool hashValid); void addRaw(Serializer &, SHANodeFormat format); @@ -216,8 +216,8 @@ public: SHAMapItem::pointer getItem() const; bool setItem(SHAMapItem::ref i, TNType type); const uint256& getTag() const { return mItem->getTag(); } - const std::vector& peekData() { return mItem->peekData(); } - std::vector getData() const { return mItem->getData(); } + Blob const& peekData() { return mItem->peekData(); } + Blob getData() const { return mItem->getData(); } // sync functions bool isFullBelow(void) const { return mFullBelow; } @@ -243,10 +243,10 @@ public: virtual ~SHAMapSyncFilter() { ; } virtual void gotNode(bool fromFilter, const SHAMapNode& id, const uint256& nodeHash, - const std::vector& nodeData, SHAMapTreeNode::TNType type) + Blob const& nodeData, SHAMapTreeNode::TNType type) { ; } - virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector& nodeData) + virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, Blob & nodeData) { return false; } }; @@ -383,14 +383,14 @@ public: void getMissingNodes(std::vector& nodeIDs, std::vector& hashes, int max, SHAMapSyncFilter* filter); bool getNodeFat(const SHAMapNode& node, std::vector& nodeIDs, - std::list >& rawNode, bool fatRoot, bool fatLeaves); + std::list& rawNode, bool fatRoot, bool fatLeaves); bool getRootNode(Serializer& s, SHANodeFormat format); std::vector getNeededHashes(int max, SHAMapSyncFilter* filter); - SMAddNode addRootNode(const uint256& hash, const std::vector& rootNode, SHANodeFormat format, + SMAddNode addRootNode(const uint256& hash, Blob const& rootNode, SHANodeFormat format, SHAMapSyncFilter* filter); - SMAddNode addRootNode(const std::vector& rootNode, SHANodeFormat format, + SMAddNode addRootNode(Blob const& rootNode, SHANodeFormat format, SHAMapSyncFilter* filter); - SMAddNode addKnownNode(const SHAMapNode& nodeID, const std::vector& rawNode, + SMAddNode addKnownNode(const SHAMapNode& nodeID, Blob const& rawNode, SHAMapSyncFilter* filter); // status functions @@ -419,18 +419,18 @@ public: bool operator==(const SHAMap& s) { return getHash() == s.getHash(); } // trusted path operations - prove a particular node is in a particular ledger - std::list > getTrustedPath(const uint256& index); - static std::vector checkTrustedPath(const uint256& ledgerHash, const uint256& leafIndex, - const std::list >& path); + std::list getTrustedPath(const uint256& index); + static Blob checkTrustedPath(const uint256& ledgerHash, const uint256& leafIndex, + const std::list& path); void walkMap(std::vector& missingNodes, int maxMissing); - bool getPath(const uint256& index, std::vector< std::vector >& nodes, SHANodeFormat format); + bool getPath(const uint256& index, std::vector< Blob >& nodes, SHANodeFormat format); bool deepCompare(SHAMap& other); virtual void dump(bool withHashes = false); - typedef std::pair< uint256, std::vector > fetchPackEntry_t; + typedef std::pair< uint256, Blob > fetchPackEntry_t; std::list getFetchPack(SHAMap* have, bool includeLeaves, int max); static void sweep() { fullBelowCache.sweep(); } diff --git a/src/cpp/ripple/SHAMapNodes.cpp b/src/cpp/ripple/SHAMapNodes.cpp index bc96721d70..813c2fdc13 100644 --- a/src/cpp/ripple/SHAMapNodes.cpp +++ b/src/cpp/ripple/SHAMapNodes.cpp @@ -159,7 +159,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, SHAMapItem::ref item, TNT updateHash(); } -SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector& rawNode, uint32 seq, +SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, Blob const& rawNode, uint32 seq, SHANodeFormat format, const uint256& hash, bool hashValid) : SHAMapNode(id), mSeq(seq), mType(tnERROR), mIsBranch(0), mFullBelow(false) { diff --git a/src/cpp/ripple/SHAMapSync.cpp b/src/cpp/ripple/SHAMapSync.cpp index e282609ea3..3dff92c6c2 100644 --- a/src/cpp/ripple/SHAMapSync.cpp +++ b/src/cpp/ripple/SHAMapSync.cpp @@ -154,7 +154,7 @@ std::vector SHAMap::getNeededHashes(int max, SHAMapSyncFilter* filter) } bool SHAMap::getNodeFat(const SHAMapNode& wanted, std::vector& nodeIDs, - std::list >& rawNodes, bool fatRoot, bool fatLeaves) + std::list& rawNodes, bool fatRoot, bool fatLeaves) { // Gets a node and some of its children boost::recursive_mutex::scoped_lock sl(mLock); @@ -203,7 +203,7 @@ bool SHAMap::getRootNode(Serializer& s, SHANodeFormat format) return true; } -SMAddNode SHAMap::addRootNode(const std::vector& rootNode, SHANodeFormat format, +SMAddNode SHAMap::addRootNode(Blob const& rootNode, SHANodeFormat format, SHAMapSyncFilter* filter) { boost::recursive_mutex::scoped_lock sl(mLock); @@ -242,7 +242,7 @@ SMAddNode SHAMap::addRootNode(const std::vector& rootNode, SHANod return SMAddNode::useful(); } -SMAddNode SHAMap::addRootNode(const uint256& hash, const std::vector& rootNode, SHANodeFormat format, +SMAddNode SHAMap::addRootNode(const uint256& hash, Blob const& rootNode, SHANodeFormat format, SHAMapSyncFilter* filter) { boost::recursive_mutex::scoped_lock sl(mLock); @@ -278,7 +278,7 @@ SMAddNode SHAMap::addRootNode(const uint256& hash, const std::vector& rawNode, +SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, Blob const& rawNode, SHAMapSyncFilter* filter) { // return value: true=okay, false=error assert(!node.isRoot()); @@ -562,7 +562,7 @@ static bool confuseMap(SHAMap &map, int count) return true; } -std::list > SHAMap::getTrustedPath(const uint256& index) +std::list SHAMap::getTrustedPath(const uint256& index) { boost::recursive_mutex::scoped_lock sl(mLock); std::stack stack = SHAMap::getStack(index, false, false); @@ -570,7 +570,7 @@ std::list > SHAMap::getTrustedPath(const uint256& ind if (stack.empty() || !stack.top()->isLeaf()) throw std::runtime_error("requested leaf not present"); - std::list< std::vector > path; + std::list< Blob > path; Serializer s; while (!stack.empty()) { @@ -608,11 +608,11 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test ) WriteLog (lsTRACE, SHAMap) << "SOURCE COMPLETE, SYNCHING"; std::vector nodeIDs, gotNodeIDs; - std::list< std::vector > gotNodes; + std::list< Blob > gotNodes; std::vector hashes; std::vector::iterator nodeIDIterator; - std::list< std::vector >::iterator rawNodeIterator; + std::list< Blob >::iterator rawNodeIterator; int passes = 0; int nodes = 0; diff --git a/src/cpp/ripple/SHAMapSync.h b/src/cpp/ripple/SHAMapSync.h index 5f8faa0066..7ed55ccb9b 100644 --- a/src/cpp/ripple/SHAMapSync.h +++ b/src/cpp/ripple/SHAMapSync.h @@ -14,9 +14,9 @@ public: ConsensusTransSetSF() { ; } virtual void gotNode(bool fromFilter, const SHAMapNode& id, const uint256& nodeHash, - const std::vector& nodeData, SHAMapTreeNode::TNType); + Blob const& nodeData, SHAMapTreeNode::TNType); - virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector& nodeData); + virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, Blob & nodeData); }; // This class is only needed on add functions @@ -28,11 +28,11 @@ public: { ; } virtual void gotNode(bool fromFilter, const SHAMapNode& id, const uint256& nodeHash, - const std::vector& nodeData, SHAMapTreeNode::TNType) + Blob const& nodeData, SHAMapTreeNode::TNType) { theApp->getHashedObjectStore().store(hotACCOUNT_NODE, mLedgerSeq, nodeData, nodeHash); } - virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector& nodeData) + virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, Blob & nodeData) { return theApp->getOPs().getFetchPack(nodeHash, nodeData); } @@ -50,13 +50,13 @@ public: { ; } virtual void gotNode(bool fromFilter, const SHAMapNode& id, const uint256& nodeHash, - const std::vector& nodeData, SHAMapTreeNode::TNType type) + Blob const& nodeData, SHAMapTreeNode::TNType type) { theApp->getHashedObjectStore().store( (type == SHAMapTreeNode::tnTRANSACTION_NM) ? hotTRANSACTION : hotTRANSACTION_NODE, mLedgerSeq, nodeData, nodeHash); } - virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector& nodeData) + virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, Blob & nodeData) { return theApp->getOPs().getFetchPack(nodeHash, nodeData); } diff --git a/src/cpp/ripple/SerializedTransaction.cpp b/src/cpp/ripple/SerializedTransaction.cpp index 24bc5ad51a..2dbf013b0f 100644 --- a/src/cpp/ripple/SerializedTransaction.cpp +++ b/src/cpp/ripple/SerializedTransaction.cpp @@ -130,7 +130,7 @@ uint256 SerializedTransaction::getTransactionID() const return getHash(sHP_TransactionID); } -std::vector SerializedTransaction::getSignature() const +Blob SerializedTransaction::getSignature() const { try { @@ -138,13 +138,13 @@ std::vector SerializedTransaction::getSignature() const } catch (...) { - return std::vector(); + return Blob (); } } void SerializedTransaction::sign(const RippleAddress& naAccountPrivate) { - std::vector signature; + Blob signature; naAccountPrivate.accountPrivateSign(getSigningHash(), signature); setFieldVL(sfTxnSignature, signature); } diff --git a/src/cpp/ripple/SerializedTransaction.h b/src/cpp/ripple/SerializedTransaction.h index 8e60414c85..cbe4e50ecc 100644 --- a/src/cpp/ripple/SerializedTransaction.h +++ b/src/cpp/ripple/SerializedTransaction.h @@ -29,8 +29,8 @@ public: std::string getText() const; // outer transaction functions / signature functions - std::vector getSignature() const; - void setSignature(const std::vector& s) { setFieldVL(sfTxnSignature, s); } + Blob getSignature() const; + void setSignature(Blob const& s) { setFieldVL(sfTxnSignature, s); } uint256 getSigningHash() const; TransactionType getTxnType() const { return mType; } @@ -38,7 +38,7 @@ public: void setTransactionFee(const STAmount& fee) { setFieldAmount(sfFee, fee); } RippleAddress getSourceAccount() const { return getFieldAccount(sfAccount); } - std::vector getSigningPubKey() const { return getFieldVL(sfSigningPubKey); } + Blob getSigningPubKey() const { return getFieldVL(sfSigningPubKey); } void setSigningPubKey(const RippleAddress& naSignPubKey); void setSourceAccount(const RippleAddress& naSource); std::string getTransactionType() const { return mFormat->t_name; } diff --git a/src/cpp/ripple/SerializedValidation.cpp b/src/cpp/ripple/SerializedValidation.cpp index 9cf2614ecb..d2360de5ba 100644 --- a/src/cpp/ripple/SerializedValidation.cpp +++ b/src/cpp/ripple/SerializedValidation.cpp @@ -40,7 +40,7 @@ void SerializedValidation::sign(const RippleAddress& raPriv) void SerializedValidation::sign(uint256& signingHash, const RippleAddress& raPriv) { signingHash = getSigningHash(); - std::vector signature; + Blob signature; raPriv.signNodePrivate(signingHash, signature); setFieldVL(sfSignature, signature); } @@ -96,12 +96,12 @@ bool SerializedValidation::isFull() const return (getFlags() & sFullFlag) != 0; } -std::vector SerializedValidation::getSignature() const +Blob SerializedValidation::getSignature() const { return getFieldVL(sfSignature); } -std::vector SerializedValidation::getSigned() const +Blob SerializedValidation::getSigned() const { Serializer s; add(s); diff --git a/src/cpp/ripple/SerializedValidation.h b/src/cpp/ripple/SerializedValidation.h index 4955b9a620..68a300af8b 100644 --- a/src/cpp/ripple/SerializedValidation.h +++ b/src/cpp/ripple/SerializedValidation.h @@ -31,8 +31,8 @@ public: bool isValid(const uint256&) const; void setTrusted() { mTrusted = true; } - std::vector getSigned() const; - std::vector getSignature() const; + Blob getSigned() const; + Blob getSignature() const; void sign(uint256& signingHash, const RippleAddress& raPrivate); void sign(const RippleAddress& raPrivate); diff --git a/src/cpp/ripple/Transaction.cpp b/src/cpp/ripple/Transaction.cpp index 797c9b2294..0ce91b0427 100644 --- a/src/cpp/ripple/Transaction.cpp +++ b/src/cpp/ripple/Transaction.cpp @@ -19,7 +19,7 @@ Transaction::Transaction(SerializedTransaction::ref sit, bool bValidate) mStatus = NEW; } -Transaction::pointer Transaction::sharedTransaction(const std::vector&vucTransaction, bool bValidate) +Transaction::pointer Transaction::sharedTransaction(Blob const& vucTransaction, bool bValidate) { try { diff --git a/src/cpp/ripple/Transaction.h b/src/cpp/ripple/Transaction.h index 1ab69c5b0f..ee406a2d17 100644 --- a/src/cpp/ripple/Transaction.h +++ b/src/cpp/ripple/Transaction.h @@ -53,7 +53,7 @@ private: public: Transaction(SerializedTransaction::ref st, bool bValidate); - static Transaction::pointer sharedTransaction(const std::vector&vucTransaction, bool bValidate); + static Transaction::pointer sharedTransaction(Blob const& vucTransaction, bool bValidate); static Transaction::pointer transactionFromSQL(Database* db, bool bValidate); Transaction( @@ -77,7 +77,7 @@ public: STAmount getFee() const { return mTransaction->getTransactionFee(); } uint32 getFromAccountSeq() const { return mTransaction->getSequence(); } uint32 getSourceTag() const { return mTransaction->getFieldU32(sfSourceTag); } - std::vector getSignature() const { return mTransaction->getSignature(); } + Blob getSignature() const { return mTransaction->getSignature(); } uint32 getLedger() const { return mInLedger; } TransStatus getStatus() const { return mStatus; } diff --git a/src/cpp/ripple/TransactionAcquire.cpp b/src/cpp/ripple/TransactionAcquire.cpp index ca7b7f689b..3024b2435e 100644 --- a/src/cpp/ripple/TransactionAcquire.cpp +++ b/src/cpp/ripple/TransactionAcquire.cpp @@ -132,7 +132,7 @@ void TransactionAcquire::trigger(Peer::ref peer) } SMAddNode TransactionAcquire::takeNodes(const std::list& nodeIDs, - const std::list< std::vector >& data, Peer::ref peer) + const std::list< Blob >& data, Peer::ref peer) { if (mComplete) { @@ -149,7 +149,7 @@ SMAddNode TransactionAcquire::takeNodes(const std::list& nodeIDs, if (nodeIDs.empty()) return SMAddNode::invalid(); std::list::const_iterator nodeIDit = nodeIDs.begin(); - std::list< std::vector >::const_iterator nodeDatait = data.begin(); + std::list< Blob >::const_iterator nodeDatait = data.begin(); ConsensusTransSetSF sf; while (nodeIDit != nodeIDs.end()) { @@ -188,7 +188,7 @@ SMAddNode TransactionAcquire::takeNodes(const std::list& nodeIDs, } void ConsensusTransSetSF::gotNode(bool fromFilter, const SHAMapNode& id, const uint256& nodeHash, - const std::vector& nodeData, SHAMapTreeNode::TNType type) + Blob const& nodeData, SHAMapTreeNode::TNType type) { if (fromFilter) return; @@ -213,7 +213,7 @@ void ConsensusTransSetSF::gotNode(bool fromFilter, const SHAMapNode& id, const u } bool ConsensusTransSetSF::haveNode(const SHAMapNode& id, const uint256& nodeHash, - std::vector& nodeData) + Blob & nodeData) { if (theApp->getTempNodeCache().retrieve(nodeHash, nodeData)) return true; diff --git a/src/cpp/ripple/TransactionMeta.cpp b/src/cpp/ripple/TransactionMeta.cpp index bf2fa478a1..f7c3ad0436 100644 --- a/src/cpp/ripple/TransactionMeta.cpp +++ b/src/cpp/ripple/TransactionMeta.cpp @@ -3,7 +3,7 @@ SETUP_LOG (TransactionMetaSet) -TransactionMetaSet::TransactionMetaSet(const uint256& txid, uint32 ledger, const std::vector& vec) : +TransactionMetaSet::TransactionMetaSet(const uint256& txid, uint32 ledger, Blob const& vec) : mTransactionID(txid), mLedger(ledger), mNodes(sfAffectedNodes, 32) { Serializer s(vec); diff --git a/src/cpp/ripple/TransactionMeta.h b/src/cpp/ripple/TransactionMeta.h index 5c04ebec81..6dfd879ae7 100644 --- a/src/cpp/ripple/TransactionMeta.h +++ b/src/cpp/ripple/TransactionMeta.h @@ -18,7 +18,7 @@ public: TransactionMetaSet() : mLedger(0), mIndex(static_cast(-1)), mResult(255) { ; } TransactionMetaSet(const uint256& txID, uint32 ledger, uint32 index) : mTransactionID(txID), mLedger(ledger), mIndex(static_cast(-1)), mResult(255) { ; } - TransactionMetaSet(const uint256& txID, uint32 ledger, const std::vector&); + TransactionMetaSet(const uint256& txID, uint32 ledger, Blob const&); void init(const uint256& transactionID, uint32 ledger); void clear() { mNodes.clear(); } diff --git a/src/cpp/ripple/UpdateTables.cpp b/src/cpp/ripple/UpdateTables.cpp index d9a6cc9fee..d9ce1c989b 100644 --- a/src/cpp/ripple/UpdateTables.cpp +++ b/src/cpp/ripple/UpdateTables.cpp @@ -45,7 +45,7 @@ static void addTxnSeqField() uint256 transID; SQL_FOREACH(db, "SELECT TransID,TxnMeta FROM Transactions;") { - std::vector rawMeta; + Blob rawMeta; int metaSize = 2048; rawMeta.resize(metaSize); metaSize = db->getBinary("TxnMeta", &*rawMeta.begin(), rawMeta.size()); diff --git a/src/cpp/ripple/Wallet.cpp b/src/cpp/ripple/Wallet.cpp index 806e2268fd..183893bb52 100644 --- a/src/cpp/ripple/Wallet.cpp +++ b/src/cpp/ripple/Wallet.cpp @@ -129,7 +129,7 @@ bool Wallet::dataFetch(const std::string& strKey, std::string& strValue) if (db->executeSQL(str(boost::format("SELECT Value FROM RPCData WHERE Key=%s;") % sqlEscape(strKey))) && db->startIterRows()) { - std::vector vucData = db->getBinary("Value"); + Blob vucData = db->getBinary("Value"); strValue.assign(vucData.begin(), vucData.end()); db->endIterRows(); diff --git a/src/cpp/ripple/WalletAddTransactor.cpp b/src/cpp/ripple/WalletAddTransactor.cpp index 73011d9754..12e1ca8ba7 100644 --- a/src/cpp/ripple/WalletAddTransactor.cpp +++ b/src/cpp/ripple/WalletAddTransactor.cpp @@ -4,8 +4,8 @@ TER WalletAddTransactor::doApply() { std::cerr << "WalletAdd>" << std::endl; - const std::vector vucPubKey = mTxn.getFieldVL(sfPublicKey); - const std::vector vucSignature = mTxn.getFieldVL(sfSignature); + Blob const vucPubKey = mTxn.getFieldVL(sfPublicKey); + Blob const vucSignature = mTxn.getFieldVL(sfSignature); const uint160 uAuthKeyID = mTxn.getFieldAccount160(sfRegularKey); const RippleAddress naMasterPubKey = RippleAddress::createAccountPublic(vucPubKey); const uint160 uDstAccountID = naMasterPubKey.getAccountID(); diff --git a/src/cpp/ripple/ripple_HashedObject.h b/src/cpp/ripple/ripple_HashedObject.h index b00da888d2..f304bf9ad8 100644 --- a/src/cpp/ripple/ripple_HashedObject.h +++ b/src/cpp/ripple/ripple_HashedObject.h @@ -39,7 +39,7 @@ public: */ HashedObject (HashedObjectType type, uint32 ledgerIndex, - std::vector const& binaryDataToCopy, + Blob const& binaryDataToCopy, uint256 const& hash) : mType (type) , mHash (hash) @@ -89,7 +89,7 @@ public: /** Retrieve the binary data. */ - std::vector const& getData() const + Blob const& getData() const { return mData; } @@ -98,7 +98,7 @@ private: HashedObjectType const mType; uint256 const mHash; uint32 const mLedgerIndex; - std::vector const mData; + Blob const mData; }; #endif diff --git a/src/cpp/ripple/ripple_HashedObjectStore.cpp b/src/cpp/ripple/ripple_HashedObjectStore.cpp index c2240a4746..448c4f7a41 100644 --- a/src/cpp/ripple/ripple_HashedObjectStore.cpp +++ b/src/cpp/ripple/ripple_HashedObjectStore.cpp @@ -71,7 +71,7 @@ HashedObject::pointer HashedObjectStore::LLRetrieve(const uint256& hash, leveldb void HashedObjectStore::LLWrite(boost::shared_ptr ptr, leveldb::DB* db) { HashedObject& obj = *ptr; - std::vector rawData(9 + obj.getData ().size()); + Blob rawData(9 + obj.getData ().size()); unsigned char* bufPtr = &rawData.front(); *reinterpret_cast(bufPtr + 0) = ntohl(obj.getIndex ()); @@ -97,7 +97,7 @@ void HashedObjectStore::LLWrite(const std::vector< boost::shared_ptr& it, set) { const HashedObject& obj = *it; - std::vector rawData(9 + obj.getData ().size()); + Blob rawData(9 + obj.getData ().size()); unsigned char* bufPtr = &rawData.front(); *reinterpret_cast(bufPtr + 0) = ntohl(obj.getIndex ()); @@ -118,7 +118,7 @@ void HashedObjectStore::LLWrite(const std::vector< boost::shared_ptr& data, const uint256& hash) + Blob const& data, const uint256& hash) { // return: false = already in cache, true = added to cache if (!theApp->getHashNodeLDB()) return true; @@ -214,7 +214,7 @@ HashedObject::pointer HashedObjectStore::retrieveLevelDB(const uint256& hash) } bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index, - const std::vector& data, const uint256& hash) + Blob const& data, const uint256& hash) { // return: false = already in cache, true = added to cache if (!theApp->getHashNodeDB()) { @@ -373,7 +373,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash) if (!theApp || !theApp->getHashNodeDB()) return obj; - std::vector data; + Blob data; std::string type; uint32 index; @@ -479,7 +479,7 @@ int HashedObjectStore::import(const std::string& file) } else { - std::vector rawData; + Blob rawData; int size = importDB->getBinary("Object", NULL, 0); rawData.resize(9 + size); unsigned char* bufPtr = &rawData.front(); diff --git a/src/cpp/ripple/ripple_HashedObjectStore.h b/src/cpp/ripple/ripple_HashedObjectStore.h index 1123b1034c..b6f2840edd 100644 --- a/src/cpp/ripple/ripple_HashedObjectStore.h +++ b/src/cpp/ripple/ripple_HashedObjectStore.h @@ -18,7 +18,7 @@ public: return mCache.getHitRate(); } - bool store (HashedObjectType type, uint32 index, const std::vector& data, + bool store (HashedObjectType type, uint32 index, Blob const& data, const uint256& hash) { if (mLevelDB) @@ -34,12 +34,12 @@ public: return retrieveSQLite(hash); } - bool storeSQLite(HashedObjectType type, uint32 index, const std::vector& data, + bool storeSQLite(HashedObjectType type, uint32 index, Blob const& data, const uint256& hash); HashedObject::pointer retrieveSQLite(const uint256& hash); void bulkWriteSQLite(Job&); - bool storeLevelDB(HashedObjectType type, uint32 index, const std::vector& data, + bool storeLevelDB(HashedObjectType type, uint32 index, Blob const& data, const uint256& hash); HashedObject::pointer retrieveLevelDB(const uint256& hash); void bulkWriteLevelDB(Job&); diff --git a/src/cpp/ripple/ripple_Peer.cpp b/src/cpp/ripple/ripple_Peer.cpp index 92fe73e233..75212b0980 100644 --- a/src/cpp/ripple/ripple_Peer.cpp +++ b/src/cpp/ripple/ripple_Peer.cpp @@ -1415,7 +1415,7 @@ void PeerImp::recvGetObjectByHash(const boost::shared_ptr > data = boost::make_shared< std::vector > + boost::shared_ptr< Blob > data = boost::make_shared< Blob > (obj.data().begin(), obj.data().end()); theApp->getOPs().addFetchPack(hash, data); @@ -1771,7 +1771,7 @@ void PeerImp::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockH return; } std::vector nodeIDs; - std::list< std::vector > rawNodes; + std::list< Blob > rawNodes; try { if(map->getNodeFat(mn, nodeIDs, rawNodes, fatRoot, fatLeaves)) @@ -1779,7 +1779,7 @@ void PeerImp::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockH assert(nodeIDs.size() == rawNodes.size()); WriteLog (lsTRACE, Peer) << "getNodeFat got " << rawNodes.size() << " nodes"; std::vector::iterator nodeIDIterator; - std::list< std::vector >::iterator rawNodeIterator; + std::list< Blob >::iterator rawNodeIterator; for(nodeIDIterator = nodeIDs.begin(), rawNodeIterator = rawNodes.begin(); nodeIDIterator != nodeIDs.end(); ++nodeIDIterator, ++rawNodeIterator) { @@ -1854,7 +1854,7 @@ void PeerImp::recvLedger(const boost::shared_ptr& packet_p if (packet.type() == ripple::liTS_CANDIDATE) { // got data for a candidate transaction set std::list nodeIDs; - std::list< std::vector > nodeData; + std::list< Blob > nodeData; for (int i = 0; i < packet.nodes().size(); ++i) { @@ -1866,7 +1866,7 @@ void PeerImp::recvLedger(const boost::shared_ptr& packet_p return; } nodeIDs.push_back(SHAMapNode(node.nodeid().data(), node.nodeid().size())); - nodeData.push_back(std::vector(node.nodedata().begin(), node.nodedata().end())); + nodeData.push_back(Blob (node.nodedata().begin(), node.nodedata().end())); } SMAddNode san = theApp->getOPs().gotTXData(shared_from_this(), hash, nodeIDs, nodeData); if (san.isInvalid()) @@ -1952,7 +1952,7 @@ void PeerImp::getSessionCookie(std::string& strDst) void PeerImp::sendHello() { std::string strCookie; - std::vector vchSig; + Blob vchSig; getSessionCookie(strCookie); mCookieHash = Serializer::getSHA512Half(strCookie);