aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base58.cpp183
-rw-r--r--src/base58.h259
-rw-r--r--src/core.cpp4
-rw-r--r--src/init.cpp8
-rw-r--r--src/leveldb/Makefile11
-rw-r--r--src/leveldb/db/filename.cc9
-rw-r--r--src/leveldb/db/log_reader.cc23
-rw-r--r--src/leveldb/db/log_test.cc40
-rw-r--r--src/leveldb/db/repair.cc1
-rw-r--r--src/leveldb/db/version_set.cc14
-rw-r--r--src/leveldb/include/leveldb/c.h1
-rw-r--r--src/leveldb/include/leveldb/db.h2
-rw-r--r--src/leveldb/include/leveldb/slice.h2
-rw-r--r--src/main.cpp22
-rw-r--r--src/miner.cpp2
-rw-r--r--src/rpcmisc.cpp2
-rw-r--r--src/rpcprotocol.cpp2
-rw-r--r--src/test/base58_tests.cpp4
-rw-r--r--src/test/util_tests.cpp12
-rw-r--r--src/util.h12
-rw-r--r--src/wallet.cpp2
-rw-r--r--src/walletdb.cpp2
22 files changed, 307 insertions, 310 deletions
diff --git a/src/base58.cpp b/src/base58.cpp
index 0b08ee3d06..5975703887 100644
--- a/src/base58.cpp
+++ b/src/base58.cpp
@@ -2,11 +2,18 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include "base58.h"
+
+#include "hash.h"
+#include "uint256.h"
+
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <vector>
#include <string>
+#include <boost/variant/apply_visitor.hpp>
+#include <boost/variant/static_visitor.hpp>
/* All alphanumeric characters except for "0", "I", "O", and "l" */
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -89,3 +96,179 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
str += pszBase58[*(it++)];
return str;
}
+
+std::string EncodeBase58(const std::vector<unsigned char>& vch) {
+ return EncodeBase58(&vch[0], &vch[0] + vch.size());
+}
+
+bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet) {
+ return DecodeBase58(str.c_str(), vchRet);
+}
+
+std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn) {
+ // add 4-byte hash check to the end
+ std::vector<unsigned char> vch(vchIn);
+ uint256 hash = Hash(vch.begin(), vch.end());
+ vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
+ return EncodeBase58(vch);
+}
+
+bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet) {
+ if (!DecodeBase58(psz, vchRet))
+ return false;
+ if (vchRet.size() < 4)
+ {
+ vchRet.clear();
+ return false;
+ }
+ // re-calculate the checksum, insure it matches the included 4-byte checksum
+ uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
+ if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
+ {
+ vchRet.clear();
+ return false;
+ }
+ vchRet.resize(vchRet.size()-4);
+ return true;
+}
+
+bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet) {
+ return DecodeBase58Check(str.c_str(), vchRet);
+}
+
+CBase58Data::CBase58Data() {
+ vchVersion.clear();
+ vchData.clear();
+}
+
+void CBase58Data::SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize) {
+ vchVersion = vchVersionIn;
+ vchData.resize(nSize);
+ if (!vchData.empty())
+ memcpy(&vchData[0], pdata, nSize);
+}
+
+void CBase58Data::SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend) {
+ SetData(vchVersionIn, (void*)pbegin, pend - pbegin);
+}
+
+bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) {
+ std::vector<unsigned char> vchTemp;
+ DecodeBase58Check(psz, vchTemp);
+ if (vchTemp.size() < nVersionBytes) {
+ vchData.clear();
+ vchVersion.clear();
+ return false;
+ }
+ vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes);
+ vchData.resize(vchTemp.size() - nVersionBytes);
+ if (!vchData.empty())
+ memcpy(&vchData[0], &vchTemp[nVersionBytes], vchData.size());
+ OPENSSL_cleanse(&vchTemp[0], vchData.size());
+ return true;
+}
+
+bool CBase58Data::SetString(const std::string& str) {
+ return SetString(str.c_str());
+}
+
+std::string CBase58Data::ToString() const {
+ std::vector<unsigned char> vch = vchVersion;
+ vch.insert(vch.end(), vchData.begin(), vchData.end());
+ return EncodeBase58Check(vch);
+}
+
+int CBase58Data::CompareTo(const CBase58Data& b58) const {
+ if (vchVersion < b58.vchVersion) return -1;
+ if (vchVersion > b58.vchVersion) return 1;
+ if (vchData < b58.vchData) return -1;
+ if (vchData > b58.vchData) return 1;
+ return 0;
+}
+
+namespace {
+ class CBitcoinAddressVisitor : public boost::static_visitor<bool> {
+ private:
+ CBitcoinAddress *addr;
+ public:
+ CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { }
+
+ bool operator()(const CKeyID &id) const { return addr->Set(id); }
+ bool operator()(const CScriptID &id) const { return addr->Set(id); }
+ bool operator()(const CNoDestination &no) const { return false; }
+ };
+};
+
+bool CBitcoinAddress::Set(const CKeyID &id) {
+ SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20);
+ return true;
+}
+
+bool CBitcoinAddress::Set(const CScriptID &id) {
+ SetData(Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20);
+ return true;
+}
+
+bool CBitcoinAddress::Set(const CTxDestination &dest) {
+ return boost::apply_visitor(CBitcoinAddressVisitor(this), dest);
+}
+
+bool CBitcoinAddress::IsValid() const {
+ bool fCorrectSize = vchData.size() == 20;
+ bool fKnownVersion = vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
+ vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
+ return fCorrectSize && fKnownVersion;
+}
+
+CTxDestination CBitcoinAddress::Get() const {
+ if (!IsValid())
+ return CNoDestination();
+ uint160 id;
+ memcpy(&id, &vchData[0], 20);
+ if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
+ return CKeyID(id);
+ else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
+ return CScriptID(id);
+ else
+ return CNoDestination();
+}
+
+bool CBitcoinAddress::GetKeyID(CKeyID &keyID) const {
+ if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
+ return false;
+ uint160 id;
+ memcpy(&id, &vchData[0], 20);
+ keyID = CKeyID(id);
+ return true;
+}
+
+bool CBitcoinAddress::IsScript() const {
+ return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
+}
+
+void CBitcoinSecret::SetKey(const CKey& vchSecret) {
+ assert(vchSecret.IsValid());
+ SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size());
+ if (vchSecret.IsCompressed())
+ vchData.push_back(1);
+}
+
+CKey CBitcoinSecret::GetKey() {
+ CKey ret;
+ ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1);
+ return ret;
+}
+
+bool CBitcoinSecret::IsValid() const {
+ bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1);
+ bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY);
+ return fExpectedFormat && fCorrectVersion;
+}
+
+bool CBitcoinSecret::SetString(const char* pszSecret) {
+ return CBase58Data::SetString(pszSecret) && IsValid();
+}
+
+bool CBitcoinSecret::SetString(const std::string& strSecret) {
+ return SetString(strSecret.c_str());
+}
diff --git a/src/base58.h b/src/base58.h
index 4fb436c5ed..70681f589a 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -15,17 +15,12 @@
#define BITCOIN_BASE58_H
#include "chainparams.h"
-#include "hash.h"
#include "key.h"
#include "script.h"
-#include "uint256.h"
#include <string>
#include <vector>
-#include <boost/variant/apply_visitor.hpp>
-#include <boost/variant/static_visitor.hpp>
-
/**
* Encode a byte sequence as a base58-encoded string.
* pbegin and pend cannot be NULL, unless both are.
@@ -35,10 +30,7 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
/**
* Encode a byte vector as a base58-encoded string
*/
-inline std::string EncodeBase58(const std::vector<unsigned char>& vch)
-{
- return EncodeBase58(&vch[0], &vch[0] + vch.size());
-}
+std::string EncodeBase58(const std::vector<unsigned char>& vch);
/**
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
@@ -51,55 +43,24 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
* Decode a base58-encoded string (str) into a byte vector (vchRet).
* return true if decoding is successful.
*/
-inline bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
-{
- return DecodeBase58(str.c_str(), vchRet);
-}
+bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);
/**
* Encode a byte vector into a base58-encoded string, including checksum
*/
-inline std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn)
-{
- // add 4-byte hash check to the end
- std::vector<unsigned char> vch(vchIn);
- uint256 hash = Hash(vch.begin(), vch.end());
- vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
- return EncodeBase58(vch);
-}
+std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn);
/**
* Decode a base58-encoded string (psz) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
-inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)
-{
- if (!DecodeBase58(psz, vchRet))
- return false;
- if (vchRet.size() < 4)
- {
- vchRet.clear();
- return false;
- }
- // re-calculate the checksum, insure it matches the included 4-byte checksum
- uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
- if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
- {
- vchRet.clear();
- return false;
- }
- vchRet.resize(vchRet.size()-4);
- return true;
-}
+inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet);
/**
* Decode a base58-encoded string (str) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
-inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet)
-{
- return DecodeBase58Check(str.c_str(), vchRet);
-}
+inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);
/**
* Base class for all base58-encoded data
@@ -114,64 +75,15 @@ protected:
typedef std::vector<unsigned char, zero_after_free_allocator<unsigned char> > vector_uchar;
vector_uchar vchData;
- CBase58Data()
- {
- vchVersion.clear();
- vchData.clear();
- }
-
- void SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize)
- {
- vchVersion = vchVersionIn;
- vchData.resize(nSize);
- if (!vchData.empty())
- memcpy(&vchData[0], pdata, nSize);
- }
-
- void SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend)
- {
- SetData(vchVersionIn, (void*)pbegin, pend - pbegin);
- }
+ CBase58Data();
+ void SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize);
+ void SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend);
public:
- bool SetString(const char* psz, unsigned int nVersionBytes = 1)
- {
- std::vector<unsigned char> vchTemp;
- DecodeBase58Check(psz, vchTemp);
- if (vchTemp.size() < nVersionBytes)
- {
- vchData.clear();
- vchVersion.clear();
- return false;
- }
- vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes);
- vchData.resize(vchTemp.size() - nVersionBytes);
- if (!vchData.empty())
- memcpy(&vchData[0], &vchTemp[nVersionBytes], vchData.size());
- OPENSSL_cleanse(&vchTemp[0], vchData.size());
- return true;
- }
-
- bool SetString(const std::string& str)
- {
- return SetString(str.c_str());
- }
-
- std::string ToString() const
- {
- std::vector<unsigned char> vch = vchVersion;
- vch.insert(vch.end(), vchData.begin(), vchData.end());
- return EncodeBase58Check(vch);
- }
-
- int CompareTo(const CBase58Data& b58) const
- {
- if (vchVersion < b58.vchVersion) return -1;
- if (vchVersion > b58.vchVersion) return 1;
- if (vchData < b58.vchData) return -1;
- if (vchData > b58.vchData) return 1;
- return 0;
- }
+ bool SetString(const char* psz, unsigned int nVersionBytes = 1);
+ bool SetString(const std::string& str);
+ std::string ToString() const;
+ int CompareTo(const CBase58Data& b58) const;
bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; }
bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; }
@@ -186,140 +98,37 @@ public:
* Script-hash-addresses have version 5 (or 196 testnet).
* The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script.
*/
-class CBitcoinAddress;
-class CBitcoinAddressVisitor : public boost::static_visitor<bool>
-{
-private:
- CBitcoinAddress *addr;
+class CBitcoinAddress : public CBase58Data {
public:
- CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { }
- bool operator()(const CKeyID &id) const;
- bool operator()(const CScriptID &id) const;
- bool operator()(const CNoDestination &no) const;
+ bool Set(const CKeyID &id);
+ bool Set(const CScriptID &id);
+ bool Set(const CTxDestination &dest);
+ bool IsValid() const;
+
+ CBitcoinAddress() {}
+ CBitcoinAddress(const CTxDestination &dest) { Set(dest); }
+ CBitcoinAddress(const std::string& strAddress) { SetString(strAddress); }
+ CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); }
+
+ CTxDestination Get() const;
+ bool GetKeyID(CKeyID &keyID) const;
+ bool IsScript() const;
};
-class CBitcoinAddress : public CBase58Data
-{
-public:
- bool Set(const CKeyID &id) {
- SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20);
- return true;
- }
-
- bool Set(const CScriptID &id) {
- SetData(Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20);
- return true;
- }
-
- bool Set(const CTxDestination &dest)
- {
- return boost::apply_visitor(CBitcoinAddressVisitor(this), dest);
- }
-
- bool IsValid() const
- {
- bool fCorrectSize = vchData.size() == 20;
- bool fKnownVersion = vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
- vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
- return fCorrectSize && fKnownVersion;
- }
-
- CBitcoinAddress()
- {
- }
-
- CBitcoinAddress(const CTxDestination &dest)
- {
- Set(dest);
- }
-
- CBitcoinAddress(const std::string& strAddress)
- {
- SetString(strAddress);
- }
-
- CBitcoinAddress(const char* pszAddress)
- {
- SetString(pszAddress);
- }
-
- CTxDestination Get() const {
- if (!IsValid())
- return CNoDestination();
- uint160 id;
- memcpy(&id, &vchData[0], 20);
- if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
- return CKeyID(id);
- else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
- return CScriptID(id);
- else
- return CNoDestination();
- }
-
- bool GetKeyID(CKeyID &keyID) const {
- if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
- return false;
- uint160 id;
- memcpy(&id, &vchData[0], 20);
- keyID = CKeyID(id);
- return true;
- }
-
- bool IsScript() const {
- return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
- }
-};
-
-bool inline CBitcoinAddressVisitor::operator()(const CKeyID &id) const { return addr->Set(id); }
-bool inline CBitcoinAddressVisitor::operator()(const CScriptID &id) const { return addr->Set(id); }
-bool inline CBitcoinAddressVisitor::operator()(const CNoDestination &id) const { return false; }
-
/**
* A base58-encoded secret key
*/
class CBitcoinSecret : public CBase58Data
{
public:
- void SetKey(const CKey& vchSecret)
- {
- assert(vchSecret.IsValid());
- SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size());
- if (vchSecret.IsCompressed())
- vchData.push_back(1);
- }
-
- CKey GetKey()
- {
- CKey ret;
- ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1);
- return ret;
- }
-
- bool IsValid() const
- {
- bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1);
- bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY);
- return fExpectedFormat && fCorrectVersion;
- }
-
- bool SetString(const char* pszSecret)
- {
- return CBase58Data::SetString(pszSecret) && IsValid();
- }
-
- bool SetString(const std::string& strSecret)
- {
- return SetString(strSecret.c_str());
- }
-
- CBitcoinSecret(const CKey& vchSecret)
- {
- SetKey(vchSecret);
- }
-
- CBitcoinSecret()
- {
- }
+ void SetKey(const CKey& vchSecret);
+ CKey GetKey();
+ bool IsValid() const;
+ bool SetString(const char* pszSecret);
+ bool SetString(const std::string& strSecret);
+
+ CBitcoinSecret(const CKey& vchSecret) { SetKey(vchSecret); }
+ CBitcoinSecret() {}
};
template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtKeyBase : public CBase58Data
diff --git a/src/core.cpp b/src/core.cpp
index cbdd24e806..7651ce9957 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -140,7 +140,7 @@ double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSiz
std::string CTransaction::ToString() const
{
std::string str;
- str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%"PRIszu", vout.size=%"PRIszu", nLockTime=%u)\n",
+ str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
GetHash().ToString().substr(0,10),
nVersion,
vin.size(),
@@ -269,7 +269,7 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMer
void CBlock::print() const
{
- LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n",
+ LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
GetHash().ToString(),
nVersion,
hashPrevBlock.ToString(),
diff --git a/src/init.cpp b/src/init.cpp
index 2c3bb02758..7007707855 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1080,12 +1080,12 @@ bool AppInit2(boost::thread_group& threadGroup)
RandAddSeedPerfmon();
//// debug print
- LogPrintf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size());
+ LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
LogPrintf("nBestHeight = %d\n", chainActive.Height());
#ifdef ENABLE_WALLET
- LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
- LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
- LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
+ LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
+ LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
+ LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
#endif
StartNode(threadGroup);
diff --git a/src/leveldb/Makefile b/src/leveldb/Makefile
index 344ff2972a..f8903b69e4 100644
--- a/src/leveldb/Makefile
+++ b/src/leveldb/Makefile
@@ -72,7 +72,7 @@ SHARED = $(SHARED1)
else
# Update db.h if you change these.
SHARED_MAJOR = 1
-SHARED_MINOR = 15
+SHARED_MINOR = 17
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
@@ -190,19 +190,20 @@ PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
+IOSARCH=-arch armv6 -arch armv7 -arch armv7s -arch arm64
.cc.o:
mkdir -p ios-x86/$(dir $@)
- $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
+ $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
mkdir -p ios-arm/$(dir $@)
- xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
+ xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk $(IOSARCH) -c $< -o ios-arm/$@
lipo ios-x86/$@ ios-arm/$@ -create -output $@
.c.o:
mkdir -p ios-x86/$(dir $@)
- $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
+ $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
mkdir -p ios-arm/$(dir $@)
- xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
+ xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk $(IOSARCH) -c $< -o ios-arm/$@
lipo ios-x86/$@ ios-arm/$@ -create -output $@
else
diff --git a/src/leveldb/db/filename.cc b/src/leveldb/db/filename.cc
index 27d750697b..da32946d99 100644
--- a/src/leveldb/db/filename.cc
+++ b/src/leveldb/db/filename.cc
@@ -29,19 +29,14 @@ std::string LogFileName(const std::string& name, uint64_t number) {
return MakeFileName(name, number, "log");
}
-// TableFileName returns the filenames we usually write to, while
-// SSTTableFileName returns the alternative filenames we also try to read from
-// for backward compatibility. For now, swap them around.
-// TODO: when compatibility is no longer necessary, swap them back
-// (TableFileName to use "ldb" and SSTTableFileName to use "sst").
std::string TableFileName(const std::string& name, uint64_t number) {
assert(number > 0);
- return MakeFileName(name, number, "sst");
+ return MakeFileName(name, number, "ldb");
}
std::string SSTTableFileName(const std::string& name, uint64_t number) {
assert(number > 0);
- return MakeFileName(name, number, "ldb");
+ return MakeFileName(name, number, "sst");
}
std::string DescriptorFileName(const std::string& dbname, uint64_t number) {
diff --git a/src/leveldb/db/log_reader.cc b/src/leveldb/db/log_reader.cc
index b35f115aad..4919216d04 100644
--- a/src/leveldb/db/log_reader.cc
+++ b/src/leveldb/db/log_reader.cc
@@ -133,7 +133,9 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch) {
case kEof:
if (in_fragmented_record) {
- ReportCorruption(scratch->size(), "partial record without end(3)");
+ // This can be caused by the writer dying immediately after
+ // writing a physical record but before completing the next; don't
+ // treat it as a corruption, just ignore the entire logical record.
scratch->clear();
}
return false;
@@ -193,13 +195,12 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result) {
eof_ = true;
}
continue;
- } else if (buffer_.size() == 0) {
- // End of file
- return kEof;
} else {
- size_t drop_size = buffer_.size();
+ // Note that if buffer_ is non-empty, we have a truncated header at the
+ // end of the file, which can be caused by the writer crashing in the
+ // middle of writing the header. Instead of considering this an error,
+ // just report EOF.
buffer_.clear();
- ReportCorruption(drop_size, "truncated record at end of file");
return kEof;
}
}
@@ -213,8 +214,14 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result) {
if (kHeaderSize + length > buffer_.size()) {
size_t drop_size = buffer_.size();
buffer_.clear();
- ReportCorruption(drop_size, "bad record length");
- return kBadRecord;
+ if (!eof_) {
+ ReportCorruption(drop_size, "bad record length");
+ return kBadRecord;
+ }
+ // If the end of the file has been reached without reading |length| bytes
+ // of payload, assume the writer died in the middle of writing the record.
+ // Don't report a corruption.
+ return kEof;
}
if (type == kZeroType && length == 0) {
diff --git a/src/leveldb/db/log_test.cc b/src/leveldb/db/log_test.cc
index 4c5cf87573..91d3caafc3 100644
--- a/src/leveldb/db/log_test.cc
+++ b/src/leveldb/db/log_test.cc
@@ -351,20 +351,32 @@ TEST(LogTest, BadRecordType) {
ASSERT_EQ("OK", MatchError("unknown record type"));
}
-TEST(LogTest, TruncatedTrailingRecord) {
+TEST(LogTest, TruncatedTrailingRecordIsIgnored) {
Write("foo");
ShrinkSize(4); // Drop all payload as well as a header byte
ASSERT_EQ("EOF", Read());
- ASSERT_EQ(kHeaderSize - 1, DroppedBytes());
- ASSERT_EQ("OK", MatchError("truncated record at end of file"));
+ // Truncated last record is ignored, not treated as an error.
+ ASSERT_EQ(0, DroppedBytes());
+ ASSERT_EQ("", ReportMessage());
}
TEST(LogTest, BadLength) {
+ const int kPayloadSize = kBlockSize - kHeaderSize;
+ Write(BigString("bar", kPayloadSize));
+ Write("foo");
+ // Least significant size byte is stored in header[4].
+ IncrementByte(4, 1);
+ ASSERT_EQ("foo", Read());
+ ASSERT_EQ(kBlockSize, DroppedBytes());
+ ASSERT_EQ("OK", MatchError("bad record length"));
+}
+
+TEST(LogTest, BadLengthAtEndIsIgnored) {
Write("foo");
ShrinkSize(1);
ASSERT_EQ("EOF", Read());
- ASSERT_EQ(kHeaderSize + 2, DroppedBytes());
- ASSERT_EQ("OK", MatchError("bad record length"));
+ ASSERT_EQ(0, DroppedBytes());
+ ASSERT_EQ("", ReportMessage());
}
TEST(LogTest, ChecksumMismatch) {
@@ -415,6 +427,24 @@ TEST(LogTest, UnexpectedFirstType) {
ASSERT_EQ("OK", MatchError("partial record without end"));
}
+TEST(LogTest, MissingLastIsIgnored) {
+ Write(BigString("bar", kBlockSize));
+ // Remove the LAST block, including header.
+ ShrinkSize(14);
+ ASSERT_EQ("EOF", Read());
+ ASSERT_EQ("", ReportMessage());
+ ASSERT_EQ(0, DroppedBytes());
+}
+
+TEST(LogTest, PartialLastIsIgnored) {
+ Write(BigString("bar", kBlockSize));
+ // Cause a bad record length in the LAST block.
+ ShrinkSize(1);
+ ASSERT_EQ("EOF", Read());
+ ASSERT_EQ("", ReportMessage());
+ ASSERT_EQ(0, DroppedBytes());
+}
+
TEST(LogTest, ErrorJoinsRecords) {
// Consider two fragmented records:
// first(R1) last(R1) first(R2) last(R2)
diff --git a/src/leveldb/db/repair.cc b/src/leveldb/db/repair.cc
index 96c9b37af1..7727fafc58 100644
--- a/src/leveldb/db/repair.cc
+++ b/src/leveldb/db/repair.cc
@@ -242,7 +242,6 @@ class Repairer {
}
void ExtractMetaData() {
- std::vector<TableInfo> kept;
for (size_t i = 0; i < table_numbers_.size(); i++) {
ScanTable(table_numbers_[i]);
}
diff --git a/src/leveldb/db/version_set.cc b/src/leveldb/db/version_set.cc
index 517edd3b18..aa83df55e4 100644
--- a/src/leveldb/db/version_set.cc
+++ b/src/leveldb/db/version_set.cc
@@ -54,20 +54,6 @@ static int64_t TotalFileSize(const std::vector<FileMetaData*>& files) {
return sum;
}
-namespace {
-std::string IntSetToString(const std::set<uint64_t>& s) {
- std::string result = "{";
- for (std::set<uint64_t>::const_iterator it = s.begin();
- it != s.end();
- ++it) {
- result += (result.size() > 1) ? "," : "";
- result += NumberToString(*it);
- }
- result += "}";
- return result;
-}
-} // namespace
-
Version::~Version() {
assert(refs_ == 0);
diff --git a/src/leveldb/include/leveldb/c.h b/src/leveldb/include/leveldb/c.h
index 1fa58866c3..1048fe3b86 100644
--- a/src/leveldb/include/leveldb/c.h
+++ b/src/leveldb/include/leveldb/c.h
@@ -9,7 +9,6 @@
Does not support:
. getters for the option types
. custom comparators that implement key shortening
- . capturing post-write-snapshot
. custom iter, db, env, cache implementations using just the C bindings
Some conventions:
diff --git a/src/leveldb/include/leveldb/db.h b/src/leveldb/include/leveldb/db.h
index 5ffb29d526..40851b2aa8 100644
--- a/src/leveldb/include/leveldb/db.h
+++ b/src/leveldb/include/leveldb/db.h
@@ -14,7 +14,7 @@ namespace leveldb {
// Update Makefile if you change these
static const int kMajorVersion = 1;
-static const int kMinorVersion = 15;
+static const int kMinorVersion = 17;
struct Options;
struct ReadOptions;
diff --git a/src/leveldb/include/leveldb/slice.h b/src/leveldb/include/leveldb/slice.h
index 74ea8fa49a..bc367986f7 100644
--- a/src/leveldb/include/leveldb/slice.h
+++ b/src/leveldb/include/leveldb/slice.h
@@ -94,7 +94,7 @@ inline bool operator!=(const Slice& x, const Slice& y) {
}
inline int Slice::compare(const Slice& b) const {
- const int min_len = (size_ < b.size_) ? size_ : b.size_;
+ const size_t min_len = (size_ < b.size_) ? size_ : b.size_;
int r = memcmp(data_, b.data_, min_len);
if (r == 0) {
if (size_ < b.size_) r = -1;
diff --git a/src/main.cpp b/src/main.cpp
index 379ca3ef74..f7c53052e1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -430,7 +430,7 @@ bool AddOrphanTx(const CTransaction& tx)
BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
- LogPrint("mempool", "stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString(),
+ LogPrint("mempool", "stored orphan tx %s (mapsz %u)\n", hash.ToString(),
mapOrphanTransactions.size());
return true;
}
@@ -3136,7 +3136,7 @@ void PrintBlockTree()
// print item
CBlock block;
ReadBlockFromDisk(block, pindex);
- LogPrintf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"\n",
+ LogPrintf("%d (blk%05u.dat:0x%x) %s tx %u\n",
pindex->nHeight,
pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos,
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()),
@@ -3463,7 +3463,7 @@ void static ProcessGetData(CNode* pfrom)
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{
RandAddSeedPerfmon();
- LogPrint("net", "received: %s (%"PRIszu" bytes)\n", strCommand, vRecv.size());
+ LogPrint("net", "received: %s (%u bytes)\n", strCommand, vRecv.size());
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
@@ -3604,7 +3604,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vAddr.size() > 1000)
{
Misbehaving(pfrom->GetId(), 20);
- return error("message addr size() = %"PRIszu"", vAddr.size());
+ return error("message addr size() = %u", vAddr.size());
}
// Store the new addresses
@@ -3667,7 +3667,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vInv.size() > MAX_INV_SZ)
{
Misbehaving(pfrom->GetId(), 20);
- return error("message inv size() = %"PRIszu"", vInv.size());
+ return error("message inv size() = %u", vInv.size());
}
LOCK(cs_main);
@@ -3706,11 +3706,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vInv.size() > MAX_INV_SZ)
{
Misbehaving(pfrom->GetId(), 20);
- return error("message getdata size() = %"PRIszu"", vInv.size());
+ return error("message getdata size() = %u", vInv.size());
}
if (fDebug || (vInv.size() != 1))
- LogPrint("net", "received getdata (%"PRIszu" invsz)\n", vInv.size());
+ LogPrint("net", "received getdata (%u invsz)\n", vInv.size());
if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
LogPrint("net", "received getdata for: %s\n", vInv[0].ToString());
@@ -3818,7 +3818,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
vEraseQueue.push_back(inv.hash);
- LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %"PRIszu")\n",
+ LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %u)\n",
pfrom->addr.ToString(), pfrom->cleanSubVer,
tx.GetHash().ToString(),
mempool.mapTx.size());
@@ -4003,7 +4003,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}
if (!(sProblem.empty())) {
- LogPrint("net", "pong %s %s: %s, %x expected, %x received, %"PRIszu" bytes\n",
+ LogPrint("net", "pong %s %s: %s, %x expected, %x received, %u bytes\n",
pfrom->addr.ToString(),
pfrom->cleanSubVer,
sProblem,
@@ -4138,7 +4138,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
bool ProcessMessages(CNode* pfrom)
{
//if (fDebug)
- // LogPrintf("ProcessMessages(%"PRIszu" messages)\n", pfrom->vRecvMsg.size());
+ // LogPrintf("ProcessMessages(%u messages)\n", pfrom->vRecvMsg.size());
//
// Message format
@@ -4166,7 +4166,7 @@ bool ProcessMessages(CNode* pfrom)
CNetMessage& msg = *it;
//if (fDebug)
- // LogPrintf("ProcessMessages(message %u msgsz, %"PRIszu" bytes, complete:%s)\n",
+ // LogPrintf("ProcessMessages(message %u msgsz, %u bytes, complete:%s)\n",
// msg.hdr.nMessageSize, msg.vRecv.size(),
// msg.complete() ? "Y" : "N");
diff --git a/src/miner.cpp b/src/miner.cpp
index 50be4fad40..94fc8e3888 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -531,7 +531,7 @@ void static BitcoinMiner(CWallet *pwallet)
CBlock *pblock = &pblocktemplate->block;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
- LogPrintf("Running BitcoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
+ LogPrintf("Running BitcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
//
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index a2694d458a..2564a3f1a6 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -187,7 +187,7 @@ CScript _createmultisig_redeemScript(const Array& params)
if ((int)keys.size() < nRequired)
throw runtime_error(
strprintf("not enough keys supplied "
- "(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired));
+ "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CPubKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp
index 652b14d187..5cbaa535ab 100644
--- a/src/rpcprotocol.cpp
+++ b/src/rpcprotocol.cpp
@@ -92,7 +92,7 @@ string HTTPReply(int nStatus, const string& strMsg, bool keepalive)
"HTTP/1.1 %d %s\r\n"
"Date: %s\r\n"
"Connection: %s\r\n"
- "Content-Length: %"PRIszu"\r\n"
+ "Content-Length: %u\r\n"
"Content-Type: application/json\r\n"
"Server: bitcoin-json-rpc/%s\r\n"
"\r\n"
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp
index 5689e69995..b81a19cfd8 100644
--- a/src/test/base58_tests.cpp
+++ b/src/test/base58_tests.cpp
@@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
continue;
}
CBitcoinAddress addrOut;
- BOOST_CHECK_MESSAGE(boost::apply_visitor(CBitcoinAddressVisitor(&addrOut), dest), "encode dest: " + strTest);
+ BOOST_CHECK_MESSAGE(addrOut.Set(dest), "encode dest: " + strTest);
BOOST_CHECK_MESSAGE(addrOut.ToString() == exp_base58string, "mismatch: " + strTest);
}
}
@@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
// Visiting a CNoDestination must fail
CBitcoinAddress dummyAddr;
CTxDestination nodest = CNoDestination();
- BOOST_CHECK(!boost::apply_visitor(CBitcoinAddressVisitor(&dummyAddr), nodest));
+ BOOST_CHECK(!dummyAddr.Set(nodest));
SelectParams(CChainParams::MAIN);
}
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index f4ca8c0539..3811569c0a 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -310,15 +310,15 @@ BOOST_AUTO_TEST_CASE(strprintf_numbers)
size_t st = 12345678; /* unsigned size_t test value */
ssize_t sst = -12345678; /* signed size_t test value */
- BOOST_CHECK(strprintf("%s %"PRIszd" %s", B, sst, E) == B" -12345678 "E);
- BOOST_CHECK(strprintf("%s %"PRIszu" %s", B, st, E) == B" 12345678 "E);
- BOOST_CHECK(strprintf("%s %"PRIszx" %s", B, st, E) == B" bc614e "E);
+ BOOST_CHECK(strprintf("%s %d %s", B, sst, E) == B" -12345678 "E);
+ BOOST_CHECK(strprintf("%s %u %s", B, st, E) == B" 12345678 "E);
+ BOOST_CHECK(strprintf("%s %x %s", B, st, E) == B" bc614e "E);
ptrdiff_t pt = 87654321; /* positive ptrdiff_t test value */
ptrdiff_t spt = -87654321; /* negative ptrdiff_t test value */
- BOOST_CHECK(strprintf("%s %"PRIpdd" %s", B, spt, E) == B" -87654321 "E);
- BOOST_CHECK(strprintf("%s %"PRIpdu" %s", B, pt, E) == B" 87654321 "E);
- BOOST_CHECK(strprintf("%s %"PRIpdx" %s", B, pt, E) == B" 5397fb1 "E);
+ BOOST_CHECK(strprintf("%s %d %s", B, spt, E) == B" -87654321 "E);
+ BOOST_CHECK(strprintf("%s %u %s", B, pt, E) == B" 87654321 "E);
+ BOOST_CHECK(strprintf("%s %x %s", B, pt, E) == B" 5397fb1 "E);
}
#undef B
#undef E
diff --git a/src/util.h b/src/util.h
index 011a40e540..27a08716dd 100644
--- a/src/util.h
+++ b/src/util.h
@@ -44,18 +44,6 @@ static const int64_t CENT = 1000000;
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
-/* Format characters for (s)size_t, ptrdiff_t.
- *
- * Define these as empty as the tinyformat-based formatting system is
- * type-safe, no special format characters are needed to specify sizes.
- */
-#define PRIszx "x"
-#define PRIszu "u"
-#define PRIszd "d"
-#define PRIpdx "x"
-#define PRIpdu "u"
-#define PRIpdd "d"
-
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 418720de93..fa7aecddb6 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1638,7 +1638,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
throw runtime_error("TopUpKeyPool() : writing generated key failed");
setKeyPool.insert(nEnd);
- LogPrintf("keypool added key %d, size=%"PRIszu"\n", nEnd, setKeyPool.size());
+ LogPrintf("keypool added key %d, size=%u\n", nEnd, setKeyPool.size());
}
}
return true;
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 359a1cef61..80e9dded5f 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -894,7 +894,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename);
return false;
}
- LogPrintf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size());
+ LogPrintf("Salvage(aggressive) found %u records\n", salvagedData.size());
bool fSuccess = allOK;
Db* pdbCopy = new Db(&dbenv.dbenv, 0);