aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml8
-rw-r--r--contrib/linearize/README.md5
-rwxr-xr-xcontrib/linearize/linearize-data.py73
-rw-r--r--depends/funcs.mk4
-rw-r--r--doc/dnsseed-policy.md3
-rw-r--r--doc/translation_process.md10
-rw-r--r--src/addrman.cpp6
-rw-r--r--src/addrman.h4
-rw-r--r--src/alert.h4
-rw-r--r--src/bloom.h2
-rw-r--r--src/chainparams.cpp1
-rw-r--r--src/checkpoints.cpp4
-rw-r--r--src/checkpoints.h2
-rw-r--r--src/core.h29
-rw-r--r--src/crypter.h2
-rw-r--r--src/init.cpp2
-rw-r--r--src/main.cpp38
-rw-r--r--src/main.h34
-rw-r--r--src/net.cpp3
-rw-r--r--src/netbase.h7
-rw-r--r--src/protocol.h15
-rw-r--r--src/qt/overviewpage.cpp2
-rw-r--r--src/qt/recentrequeststablemodel.h12
-rw-r--r--src/qt/test/paymentrequestdata.h4
-rw-r--r--src/qt/test/paymentservertests.cpp9
-rw-r--r--src/qt/test/paymentservertests.h8
-rw-r--r--src/qt/test/test_main.cpp7
-rw-r--r--src/qt/test/uritests.cpp4
-rw-r--r--src/qt/test/uritests.h4
-rw-r--r--src/qt/transactionrecord.cpp2
-rw-r--r--src/qt/transactiontablemodel.cpp14
-rw-r--r--src/qt/transactionview.cpp2
-rw-r--r--src/qt/walletmodel.h36
-rw-r--r--src/rpcblockchain.cpp2
-rw-r--r--src/rpcrawtransaction.cpp2
-rw-r--r--src/rpcwallet.cpp2
-rw-r--r--src/serialize.h6
-rw-r--r--src/uint256.h5
-rw-r--r--src/wallet.cpp6
-rw-r--r--src/wallet.h56
-rw-r--r--src/walletdb.h2
41 files changed, 245 insertions, 196 deletions
diff --git a/.travis.yml b/.travis.yml
index 2073e71769..379a0e1df7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,10 +14,12 @@ env:
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
+ - SDK_URL=https://bitcoincore.org/depends-sources/sdks
cache:
apt: true
directories:
- depends/built
+ - depends/sdk-sources
- $HOME/.ccache
matrix:
fast_finish: true
@@ -30,6 +32,8 @@ matrix:
env: HOST=x86_64-unknown-linux-gnu RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat"
- compiler: "true 4"
env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat"
+ - compiler: "true 5"
+ env: HOST=x86_64-apple-darwin11 PACKAGES="gcc-multilib g++-multilib cmake libcap-dev libz-dev libbz2-dev" OSX_SDK=10.7 GOAL="deploy"
- compiler: "true 6"
env: HOST=x86_64-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev" GOAL="deploy"
- compiler: "true 7"
@@ -39,7 +43,9 @@ install:
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-upgrade -qq $PACKAGES; fi
before_script:
- unset CC; unset CXX
- - mkdir -p depends/SDKs
+ - mkdir -p depends/SDKs depends/sdk-sources
+ - if [ -n "$OSX_SDK" -a ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then wget $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -O depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
+ - if [ -n "$OSX_SDK" -a -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
- make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS || (echo "Build failure. Verbose build follows." && make -C depends V=1 HOST=$HOST $DEP_OPTS)
script:
- OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
diff --git a/contrib/linearize/README.md b/contrib/linearize/README.md
index b5c6e7824e..157586e4d4 100644
--- a/contrib/linearize/README.md
+++ b/contrib/linearize/README.md
@@ -27,6 +27,7 @@ output.
Optional config file setting for linearize-data:
* "netmagic": network magic number
* "max_out_sz": maximum output file size (default 1000*1000*1000)
-* "split_year": Split files when a new year is first seen, in addition to
+* "split_timestamp": Split files when a new month is first seen, in addition to
reaching a maximum file size.
-
+* "file_timestamp": Set each file's last-modified time to that of the
+most recent block in that file.
diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py
index ea94f25fae..383bb38198 100755
--- a/contrib/linearize/linearize-data.py
+++ b/contrib/linearize/linearize-data.py
@@ -10,11 +10,13 @@
import json
import struct
import re
+import os
import base64
import httplib
import sys
import hashlib
import datetime
+import time
settings = {}
@@ -58,10 +60,12 @@ def calc_hash_str(blk_hdr):
hash_str = hash.encode('hex')
return hash_str
-def get_blk_year(blk_hdr):
+def get_blk_dt(blk_hdr):
members = struct.unpack("<I", blk_hdr[68:68+4])
- dt = datetime.datetime.fromtimestamp(members[0])
- return dt.year
+ nTime = members[0]
+ dt = datetime.datetime.fromtimestamp(nTime)
+ dt_ym = datetime.datetime(dt.year, dt.month, 1)
+ return (dt_ym, nTime)
def get_block_hashes(settings):
blkindex = []
@@ -86,16 +90,21 @@ def copydata(settings, blkindex, blkset):
outFn = 0
outsz = 0
outF = None
+ outFname = None
blkCount = 0
- lastYear = 0
- splitYear = False
+ lastDate = datetime.datetime(2000, 1, 1)
+ highTS = 1408893517 - 315360000
+ timestampSplit = False
fileOutput = True
+ setFileTime = False
maxOutSz = settings['max_out_sz']
if 'output' in settings:
fileOutput = False
- if settings['split_year'] != 0:
- splitYear = True
+ if settings['file_timestamp'] != 0:
+ setFileTime = True
+ if settings['split_timestamp'] != 0:
+ timestampSplit = True
while True:
if not inF:
@@ -125,36 +134,49 @@ def copydata(settings, blkindex, blkset):
print("Skipping unknown block " + hash_str)
continue
+ if blkindex[blkCount] != hash_str:
+ print("Out of order block.")
+ print("Expected " + blkindex[blkCount])
+ print("Got " + hash_str)
+ sys.exit(1)
+
if not fileOutput and ((outsz + inLen) > maxOutSz):
outF.close()
+ if setFileTime:
+ os.utime(outFname, (int(time.time()), highTS))
outF = None
+ outFname = None
outFn = outFn + 1
outsz = 0
- if splitYear:
- blkYear = get_blk_year(blk_hdr)
- if blkYear > lastYear:
- print("New year " + str(blkYear) + " @ " + hash_str)
- lastYear = blkYear
- if outF:
- outF.close()
- outF = None
- outFn = outFn + 1
- outsz = 0
+ (blkDate, blkTS) = get_blk_dt(blk_hdr)
+ if timestampSplit and (blkDate > lastDate):
+ print("New month " + blkDate.strftime("%Y-%m") + " @ " + hash_str)
+ lastDate = blkDate
+ if outF:
+ outF.close()
+ if setFileTime:
+ os.utime(outFname, (int(time.time()), highTS))
+ outF = None
+ outFname = None
+ outFn = outFn + 1
+ outsz = 0
if not outF:
if fileOutput:
- fname = settings['output_file']
+ outFname = settings['output_file']
else:
- fname = "%s/blk%05d.dat" % (settings['output'], outFn)
- print("Output file" + fname)
- outF = open(fname, "wb")
+ outFname = "%s/blk%05d.dat" % (settings['output'], outFn)
+ print("Output file" + outFname)
+ outF = open(outFname, "wb")
outF.write(inhdr)
outF.write(rawblock)
outsz = outsz + inLen + 8
blkCount = blkCount + 1
+ if blkTS > highTS:
+ highTS = blkTS
if (blkCount % 1000) == 0:
print("Wrote " + str(blkCount) + " blocks")
@@ -184,13 +206,16 @@ if __name__ == '__main__':
settings['input'] = 'input'
if 'hashlist' not in settings:
settings['hashlist'] = 'hashlist.txt'
- if 'split_year' not in settings:
- settings['split_year'] = 0
+ if 'file_timestamp' not in settings:
+ settings['file_timestamp'] = 0
+ if 'split_timestamp' not in settings:
+ settings['split_timestamp'] = 0
if 'max_out_sz' not in settings:
settings['max_out_sz'] = 1000L * 1000 * 1000
settings['max_out_sz'] = long(settings['max_out_sz'])
- settings['split_year'] = int(settings['split_year'])
+ settings['split_timestamp'] = int(settings['split_timestamp'])
+ settings['file_timestamp'] = int(settings['file_timestamp'])
settings['netmagic'] = settings['netmagic'].decode('hex')
if 'output_file' not in settings and 'output' not in settings:
diff --git a/depends/funcs.mk b/depends/funcs.mk
index 280706efb3..28bfb85492 100644
--- a/depends/funcs.mk
+++ b/depends/funcs.mk
@@ -22,8 +22,8 @@ endef
define fetch_file
(test -f $(SOURCES_PATH)/$(4) || \
( mkdir -p $$($(1)_extract_dir) && \
- ( $(build_DOWNLOAD) "$$($(1)_extract_dir)/$(3).temp" "$(2)/$(3)" || \
- $(build_DOWNLOAD) "$$($(1)_extract_dir)/$(3).temp" "$(FALLBACK_DOWNLOAD_PATH)/$(3)" ) && \
+ ( $(build_DOWNLOAD) "$$($(1)_extract_dir)/$(4).temp" "$(2)/$(3)" || \
+ $(build_DOWNLOAD) "$$($(1)_extract_dir)/$(4).temp" "$(FALLBACK_DOWNLOAD_PATH)/$(3)" ) && \
echo "$(5) $$($(1)_extract_dir)/$(4).temp" > $$($(1)_extract_dir)/.$(4).hash && \
$(build_SHA256SUM) -c $$($(1)_extract_dir)/.$(4).hash && \
mv $$($(1)_extract_dir)/$(4).temp $(SOURCES_PATH)/$(4) ))
diff --git a/doc/dnsseed-policy.md b/doc/dnsseed-policy.md
index 73e307f7cd..66a1757ac5 100644
--- a/doc/dnsseed-policy.md
+++ b/doc/dnsseed-policy.md
@@ -3,6 +3,9 @@ Expectations for DNS Seed operators
Bitcoin Core attempts to minimize the level of trust in DNS seeds,
but DNS seeds still pose a small amount of risk for the network.
+As such, DNS seeds must be run by entities which have some minimum
+level of trust within the Bitcoin community.
+
Other implementations of Bitcoin software may also use the same
seeds and may be more exposed. In light of this exposure this
document establishes some basic expectations for the expectations
diff --git a/doc/translation_process.md b/doc/translation_process.md
index 61a0a0ffed..9475b1dc72 100644
--- a/doc/translation_process.md
+++ b/doc/translation_process.md
@@ -17,10 +17,12 @@ automated.
This file must be updated whenever a new translation is added. Please note that
files must end with `.qm`, not `.ts`.
- <qresource prefix="/translations">
- <file alias="en">locale/bitcoin_en.qm</file>
- ...
- </qresource>
+```xml
+<qresource prefix="/translations">
+ <file alias="en">locale/bitcoin_en.qm</file>
+ ...
+</qresource>
+```
### src/qt/locale/
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 704766dbf8..68948ac7ff 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -45,13 +45,13 @@ bool CAddrInfo::IsTerrible(int64_t nNow) const
if (nTime > nNow + 10*60) // came in a flying DeLorean
return true;
- if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*86400) // not seen in over a month
+ if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*24*60*60) // not seen in recent history
return true;
- if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried three times and never a success
+ if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried N times and never a success
return true;
- if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*86400 && nAttempts>=ADDRMAN_MAX_FAILURES) // 10 successive failures in the last week
+ if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*24*60*60 && nAttempts>=ADDRMAN_MAX_FAILURES) // N successive failures in the last week
return true;
return false;
diff --git a/src/addrman.h b/src/addrman.h
index 0790802b5c..90507cb458 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -46,7 +46,7 @@ private:
public:
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -268,7 +268,7 @@ public:
// This format is more complex, but significantly smaller (at most 1.5 MiB), and supports
// changes to the ADDRMAN_ parameters without breaking the on-disk structure.
//
- // We don't use IMPLEMENT_SERIALIZE since the serialization and deserialization code has
+ // We don't use ADD_SERIALIZE_METHODS since the serialization and deserialization code has
// very little in common.
template<typename Stream>
void Serialize(Stream &s, int nType, int nVersionDummy) const
diff --git a/src/alert.h b/src/alert.h
index 4a8736d60b..5ecf94cea8 100644
--- a/src/alert.h
+++ b/src/alert.h
@@ -46,7 +46,7 @@ public:
std::string strStatusBar;
std::string strReserved;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -84,7 +84,7 @@ public:
SetNull();
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
diff --git a/src/bloom.h b/src/bloom.h
index 4a710928cc..143e3b4c79 100644
--- a/src/bloom.h
+++ b/src/bloom.h
@@ -62,7 +62,7 @@ public:
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn);
CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index ce99f268f3..bfe50d77d5 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -99,7 +99,6 @@ public:
vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org"));
vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com"));
vSeeds.push_back(CDNSSeedData("bitnodes.io", "seed.bitnodes.io"));
- vSeeds.push_back(CDNSSeedData("open-nodes.org", "seeds.bitcoin.open-nodes.org"));
vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));
base58Prefixes[PUBKEY_ADDRESS] = list_of(0);
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp
index 717f0b90fe..c41deea7ce 100644
--- a/src/checkpoints.cpp
+++ b/src/checkpoints.cpp
@@ -146,7 +146,7 @@ namespace Checkpoints {
return checkpoints.rbegin()->first;
}
- CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex)
+ CBlockIndex* GetLastCheckpoint()
{
if (!fEnabled)
return NULL;
@@ -156,7 +156,7 @@ namespace Checkpoints {
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
{
const uint256& hash = i.second;
- std::map<uint256, CBlockIndex*>::const_iterator t = mapBlockIndex.find(hash);
+ BlockMap::const_iterator t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end())
return t->second;
}
diff --git a/src/checkpoints.h b/src/checkpoints.h
index 52cdc35559..6d3f2d4935 100644
--- a/src/checkpoints.h
+++ b/src/checkpoints.h
@@ -22,7 +22,7 @@ namespace Checkpoints {
int GetTotalBlocksEstimate();
// Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
- CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex);
+ CBlockIndex* GetLastCheckpoint();
double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks = true);
diff --git a/src/core.h b/src/core.h
index 34c00c4142..cde8d8b3fe 100644
--- a/src/core.h
+++ b/src/core.h
@@ -31,7 +31,7 @@ public:
COutPoint() { SetNull(); }
COutPoint(uint256 hashIn, uint32_t nIn) { hash = hashIn; n = nIn; }
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -91,7 +91,7 @@ public:
explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=std::numeric_limits<unsigned int>::max());
CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=std::numeric_limits<uint32_t>::max());
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -145,7 +145,7 @@ public:
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
std::string ToString() const;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -170,7 +170,7 @@ public:
CTxOut(int64_t nValueIn, CScript scriptPubKeyIn);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -253,18 +253,16 @@ public:
CTransaction& operator=(const CTransaction& tx);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
READWRITE(*const_cast<int32_t*>(&this->nVersion));
nVersion = this->nVersion;
READWRITE(*const_cast<std::vector<CTxIn>*>(&vin));
READWRITE(*const_cast<std::vector<CTxOut>*>(&vout));
READWRITE(*const_cast<uint32_t*>(&nLockTime));
- if (fRead)
+ if (ser_action.ForRead())
UpdateHash();
}
@@ -313,7 +311,7 @@ struct CMutableTransaction
CMutableTransaction();
CMutableTransaction(const CTransaction& tx);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -342,12 +340,11 @@ public:
CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { }
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
- if (!fRead) {
+ if (!ser_action.ForRead()) {
uint64_t nVal = CompressAmount(txout.nValue);
READWRITE(VARINT(nVal));
} else {
@@ -410,7 +407,7 @@ public:
// undo information for all txins
std::vector<CTxInUndo> vprevout;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -443,7 +440,7 @@ public:
SetNull();
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -500,7 +497,7 @@ public:
*((CBlockHeader*)this) = header;
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -550,7 +547,7 @@ struct CBlockLocator
vHave = vHaveIn;
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
diff --git a/src/crypter.h b/src/crypter.h
index 59efc76508..c7424c9b20 100644
--- a/src/crypter.h
+++ b/src/crypter.h
@@ -43,7 +43,7 @@ public:
// such as the various parameters to scrypt
std::vector<unsigned char> vchOtherDerivationParameters;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
diff --git a/src/init.cpp b/src/init.cpp
index b8988f8b75..31f64878fb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1031,7 +1031,7 @@ bool AppInit2(boost::thread_group& threadGroup)
{
string strMatch = mapArgs["-printblock"];
int nFound = 0;
- for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
+ for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{
uint256 hash = (*mi).first;
if (boost::algorithm::starts_with(hash.ToString(), strMatch))
diff --git a/src/main.cpp b/src/main.cpp
index 4aebdadd3b..2479beabdd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -38,7 +38,7 @@ using namespace boost;
CCriticalSection cs_main;
-map<uint256, CBlockIndex*> mapBlockIndex;
+BlockMap mapBlockIndex;
CChain chainActive;
int64_t nTimeBestReceived = 0;
CWaitableCriticalSection csBestBlock;
@@ -328,7 +328,7 @@ void ProcessBlockAvailability(NodeId nodeid) {
assert(state != NULL);
if (state->hashLastUnknownBlock != 0) {
- map<uint256, CBlockIndex*>::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock);
+ BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock);
if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) {
if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork)
state->pindexBestKnownBlock = itOld->second;
@@ -344,7 +344,7 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
ProcessBlockAvailability(nodeid);
- map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(hash);
+ BlockMap::iterator it = mapBlockIndex.find(hash);
if (it != mapBlockIndex.end() && it->second->nChainWork > 0) {
// An actually better block was announced.
if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork)
@@ -434,7 +434,7 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
CBlockIndex *CChain::FindFork(const CBlockLocator &locator) const {
// Find the first block the caller has in the main chain
BOOST_FOREACH(const uint256& hash, locator.vHave) {
- std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
+ BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
{
CBlockIndex* pindex = (*mi).second;
@@ -2068,7 +2068,7 @@ CBlockIndex* AddToBlockIndex(CBlockHeader& block)
{
// Check for duplicate
uint256 hash = block.GetHash();
- std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(hash);
+ BlockMap::iterator it = mapBlockIndex.find(hash);
if (it != mapBlockIndex.end())
return it->second;
@@ -2079,9 +2079,9 @@ CBlockIndex* AddToBlockIndex(CBlockHeader& block)
LOCK(cs_nBlockSequenceId);
pindexNew->nSequenceId = nBlockSequenceId++;
}
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
+ BlockMap::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
pindexNew->phashBlock = &((*mi).first);
- map<uint256, CBlockIndex*>::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock);
+ BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock);
if (miPrev != mapBlockIndex.end())
{
pindexNew->pprev = (*miPrev).second;
@@ -2294,7 +2294,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
AssertLockHeld(cs_main);
// Check for duplicate
uint256 hash = block.GetHash();
- std::map<uint256, CBlockIndex*>::iterator miSelf = mapBlockIndex.find(hash);
+ BlockMap::iterator miSelf = mapBlockIndex.find(hash);
CBlockIndex *pindex = NULL;
if (miSelf != mapBlockIndex.end()) {
pindex = miSelf->second;
@@ -2302,7 +2302,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
return state.Invalid(error("AcceptBlock() : block is marked invalid"), 0, "duplicate");
}
- CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint();
if (pcheckpoint && block.hashPrevBlock != (chainActive.Tip() ? chainActive.Tip()->GetBlockHash() : uint256(0)))
{
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
@@ -2323,7 +2323,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
CBlockIndex* pindexPrev = NULL;
int nHeight = 0;
if (hash != Params().HashGenesisBlock()) {
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
+ BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
if (mi == mapBlockIndex.end())
return state.DoS(10, error("AcceptBlock() : prev block not found"), 0, "bad-prevblk");
pindexPrev = (*mi).second;
@@ -2345,7 +2345,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
REJECT_CHECKPOINT, "checkpoint mismatch");
// Don't accept any forks from the main chain prior to last checkpoint
- CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint();
if (pcheckpoint && nHeight < pcheckpoint->nHeight)
return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight));
@@ -2517,7 +2517,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
return error("ProcessBlock() : CheckBlock FAILED");
// If we don't already have its previous block (with full data), shunt it off to holding area until we get it
- std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pblock->hashPrevBlock);
+ BlockMap::iterator it = mapBlockIndex.find(pblock->hashPrevBlock);
if (pblock->hashPrevBlock != 0 && (it == mapBlockIndex.end() || !(it->second->nStatus & BLOCK_HAVE_DATA)))
{
LogPrintf("ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n", (unsigned long)mapOrphanBlocks.size(), pblock->hashPrevBlock.ToString());
@@ -2799,7 +2799,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
return NULL;
// Return existing
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
+ BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
return (*mi).second;
@@ -2876,7 +2876,7 @@ bool static LoadBlockIndexDB()
LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
// Load pointer to end of best chain
- std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
+ BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
if (it == mapBlockIndex.end())
return true;
chainActive.SetTip(it->second);
@@ -3034,7 +3034,7 @@ void PrintBlockTree()
AssertLockHeld(cs_main);
// pre-compute tree structure
map<CBlockIndex*, vector<CBlockIndex*> > mapNext;
- for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
+ for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{
CBlockIndex* pindex = (*mi).second;
mapNext[pindex->pprev].push_back(pindex);
@@ -3280,13 +3280,13 @@ void static ProcessGetData(CNode* pfrom)
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
{
bool send = false;
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash);
+ BlockMap::iterator mi = mapBlockIndex.find(inv.hash);
if (mi != mapBlockIndex.end())
{
// If the requested block is at a height below our last
// checkpoint, only serve it if it's in the checkpointed chain
int nHeight = mi->second->nHeight;
- CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint();
if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
if (!chainActive.Contains(mi->second))
{
@@ -3711,7 +3711,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (locator.IsNull())
{
// If locator is null, return the hashStop block
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashStop);
+ BlockMap::iterator mi = mapBlockIndex.find(hashStop);
if (mi == mapBlockIndex.end())
return true;
pindex = (*mi).second;
@@ -4513,7 +4513,7 @@ public:
CMainCleanup() {}
~CMainCleanup() {
// block headers
- std::map<uint256, CBlockIndex*>::iterator it1 = mapBlockIndex.begin();
+ BlockMap::iterator it1 = mapBlockIndex.begin();
for (; it1 != mapBlockIndex.end(); it1++)
delete (*it1).second;
mapBlockIndex.clear();
diff --git a/src/main.h b/src/main.h
index 31a1131b83..8c0a743e24 100644
--- a/src/main.h
+++ b/src/main.h
@@ -29,6 +29,8 @@
#include <utility>
#include <vector>
+#include <boost/unordered_map.hpp>
+
class CBlockIndex;
class CBloomFilter;
class CInv;
@@ -81,11 +83,16 @@ static const unsigned char REJECT_DUST = 0x41;
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
static const unsigned char REJECT_CHECKPOINT = 0x43;
+struct BlockHasher
+{
+ size_t operator()(const uint256& hash) const { return hash.GetLow64(); }
+};
extern CScript COINBASE_FLAGS;
extern CCriticalSection cs_main;
extern CTxMemPool mempool;
-extern std::map<uint256, CBlockIndex*> mapBlockIndex;
+typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
+extern BlockMap mapBlockIndex;
extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockSize;
extern const std::string strMessageMagic;
@@ -197,7 +204,7 @@ struct CDiskBlockPos
int nFile;
unsigned int nPos;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -230,7 +237,7 @@ struct CDiskTxPos : public CDiskBlockPos
{
unsigned int nTxOffset; // after header
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -313,7 +320,7 @@ class CBlockUndo
public:
std::vector<CTxUndo> vtxundo; // for all but the coinbase
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -420,16 +427,14 @@ protected:
public:
// serialization implementation
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
READWRITE(nTransactions);
READWRITE(vHash);
std::vector<unsigned char> vBytes;
- if (fRead) {
+ if (ser_action.ForRead()) {
READWRITE(vBytes);
CPartialMerkleTree &us = *(const_cast<CPartialMerkleTree*>(this));
us.vBits.resize(vBytes.size() * 8);
@@ -498,7 +503,7 @@ public:
uint64_t nTimeFirst; // earliest time of block in file
uint64_t nTimeLast; // latest time of block in file
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -548,15 +553,16 @@ enum BlockStatus {
BLOCK_VALID_TRANSACTIONS = 3, // only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid, no duplicate txids, sigops, size, merkle root
BLOCK_VALID_CHAIN = 4, // outputs do not overspend inputs, no double spends, coinbase output ok, immature coinbase spends, BIP30
BLOCK_VALID_SCRIPTS = 5, // scripts/signatures ok
- BLOCK_VALID_MASK = 7,
+ BLOCK_VALID_MASK = BLOCK_VALID_HEADER | BLOCK_VALID_TREE | BLOCK_VALID_TRANSACTIONS |
+ BLOCK_VALID_CHAIN | BLOCK_VALID_SCRIPTS,
BLOCK_HAVE_DATA = 8, // full block available in blk*.dat
BLOCK_HAVE_UNDO = 16, // undo data available in rev*.dat
- BLOCK_HAVE_MASK = 24,
+ BLOCK_HAVE_MASK = BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO,
BLOCK_FAILED_VALID = 32, // stage after last reached validness failed
BLOCK_FAILED_CHILD = 64, // descends from failed block
- BLOCK_FAILED_MASK = 96
+ BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD,
};
/** The block chain is a tree shaped structure starting with the
@@ -772,7 +778,7 @@ public:
hashPrev = (pprev ? pprev->GetBlockHash() : 0);
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -994,7 +1000,7 @@ public:
// thus the filter will likely be modified.
CMerkleBlock(const CBlock& block, CBloomFilter& filter);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
diff --git a/src/net.cpp b/src/net.cpp
index 3966706207..2546826f9a 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1080,8 +1080,6 @@ void ThreadSocketHandler()
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
-
- MilliSleep(10);
}
}
@@ -1791,7 +1789,6 @@ bool StopNode()
if (semOutbound)
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post();
- MilliSleep(50);
DumpAddresses();
return true;
diff --git a/src/netbase.h b/src/netbase.h
index 9b52c0a415..9fc5c72eb8 100644
--- a/src/netbase.h
+++ b/src/netbase.h
@@ -88,7 +88,7 @@ class CNetAddr
friend bool operator!=(const CNetAddr& a, const CNetAddr& b);
friend bool operator<(const CNetAddr& a, const CNetAddr& b);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -150,15 +150,14 @@ class CService : public CNetAddr
CService(const struct in6_addr& ipv6Addr, unsigned short port);
CService(const struct sockaddr_in6& addr);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
READWRITE(FLATDATA(ip));
unsigned short portN = htons(port);
READWRITE(portN);
- if (fRead)
+ if (ser_action.ForRead())
port = ntohs(portN);
}
};
diff --git a/src/protocol.h b/src/protocol.h
index e4b0991774..82d29e66de 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -35,7 +35,7 @@ class CMessageHeader
std::string GetCommand() const;
bool IsValid() const;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -85,20 +85,17 @@ class CAddress : public CService
void Init();
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
- CAddress* pthis = const_cast<CAddress*>(this);
- if (fRead)
- pthis->Init();
+ if (ser_action.ForRead())
+ Init();
if (nType & SER_DISK)
READWRITE(nVersion);
if ((nType & SER_DISK) ||
(nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
- READWRITE(nTime);
+ READWRITE(nTime);
READWRITE(nServices);
READWRITE(*(CService*)this);
}
@@ -122,7 +119,7 @@ class CInv
CInv(int typeIn, const uint256& hashIn);
CInv(const std::string& strType, const uint256& hashIn);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index 15501b8a8a..90762bea5d 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -172,7 +172,7 @@ void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64
// for symmetry reasons also show immature label when the watch-only one is shown
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
- ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
+ ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
}
// show/hide watch-only labels
diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h
index a558aa4942..3df5971823 100644
--- a/src/qt/recentrequeststablemodel.h
+++ b/src/qt/recentrequeststablemodel.h
@@ -24,23 +24,19 @@ public:
QDateTime date;
SendCoinsRecipient recipient;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
- RecentRequestEntry* pthis = const_cast<RecentRequestEntry*>(this);
-
unsigned int nDate = date.toTime_t();
- READWRITE(pthis->nVersion);
- nVersion = pthis->nVersion;
+ READWRITE(this->nVersion);
+ nVersion = this->nVersion;
READWRITE(id);
READWRITE(nDate);
READWRITE(recipient);
- if (fRead)
+ if (ser_action.ForRead())
date = QDateTime::fromTime_t(nDate);
}
};
diff --git a/src/qt/test/paymentrequestdata.h b/src/qt/test/paymentrequestdata.h
index 49558165f0..aeaa7d89a0 100644
--- a/src/qt/test/paymentrequestdata.h
+++ b/src/qt/test/paymentrequestdata.h
@@ -1,3 +1,7 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
//
// Data for paymentservertests.cpp
//
diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp
index e92a7d2b1a..5d7fe96285 100644
--- a/src/qt/test/paymentservertests.cpp
+++ b/src/qt/test/paymentservertests.cpp
@@ -1,3 +1,7 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
#include "paymentservertests.h"
#include "optionsmodel.h"
@@ -21,7 +25,6 @@ X509 *parse_b64der_cert(const char* cert_data)
return cert;
}
-
//
// Test payment request handling
//
@@ -30,7 +33,7 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig
{
RecipientCatcher sigCatcher;
QObject::connect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)),
- &sigCatcher, SLOT(getRecipient(SendCoinsRecipient)));
+ &sigCatcher, SLOT(getRecipient(SendCoinsRecipient)));
// Write data to a temp file:
QTemporaryFile f;
@@ -48,7 +51,7 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig
QCoreApplication::sendEvent(&object, &event);
QObject::disconnect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)),
- &sigCatcher, SLOT(getRecipient(SendCoinsRecipient)));
+ &sigCatcher, SLOT(getRecipient(SendCoinsRecipient)));
// Return results from sigCatcher
return sigCatcher.recipient;
diff --git a/src/qt/test/paymentservertests.h b/src/qt/test/paymentservertests.h
index 884e535a60..9b6400b0d5 100644
--- a/src/qt/test/paymentservertests.h
+++ b/src/qt/test/paymentservertests.h
@@ -1,3 +1,7 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
#ifndef PAYMENTSERVERTESTS_H
#define PAYMENTSERVERTESTS_H
@@ -15,8 +19,8 @@ private slots:
};
// Dummy class to receive paymentserver signals.
-// If SendCoinsRecipient was a proper QObject, then we could use
-// QSignalSpy... but it's not.
+// If SendCoinsRecipient was a proper QObject, then
+// we could use QSignalSpy... but it's not.
class RecipientCatcher : public QObject
{
Q_OBJECT
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index 03a2381c06..f2161c2f79 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -1,11 +1,16 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif
+#include "uritests.h"
+
#ifdef ENABLE_WALLET
#include "paymentservertests.h"
#endif
-#include "uritests.h"
#include <QCoreApplication>
#include <QObject>
diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp
index 5c0f4406a7..78a7b1b9b4 100644
--- a/src/qt/test/uritests.cpp
+++ b/src/qt/test/uritests.cpp
@@ -1,3 +1,7 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
#include "uritests.h"
#include "guiutil.h"
diff --git a/src/qt/test/uritests.h b/src/qt/test/uritests.h
index 17d4280a90..1ea6d9f075 100644
--- a/src/qt/test/uritests.h
+++ b/src/qt/test/uritests.h
@@ -1,3 +1,7 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
#ifndef URITESTS_H
#define URITESTS_H
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index d7bd25e08b..20c1449c92 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -170,7 +170,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
// Find the block the tx is in
CBlockIndex* pindex = NULL;
- std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(wtx.hashBlock);
+ BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock);
if (mi != mapBlockIndex.end())
pindex = (*mi).second;
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 1a1f726bf8..734c7afc4e 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -394,19 +394,25 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
{
+ QString watchAddress;
+ if (tooltip) {
+ // Mark transactions involving watch-only addresses by adding " (watch-only)"
+ watchAddress = wtx->involvesWatchAddress ? QString(" (") + tr("watch-only") + QString(")") : "";
+ }
+
switch(wtx->type)
{
case TransactionRecord::RecvFromOther:
- return QString::fromStdString(wtx->address);
+ return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
- return lookupAddress(wtx->address, tooltip);
+ return lookupAddress(wtx->address, tooltip) + watchAddress;
case TransactionRecord::SendToOther:
- return QString::fromStdString(wtx->address);
+ return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::SendToSelf:
default:
- return tr("(n/a)");
+ return tr("(n/a)") + watchAddress;
}
}
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index 2d34d58129..a7ba100cd2 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -331,7 +331,7 @@ void TransactionView::exportClicked()
writer.setModel(transactionProxyModel);
writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
if (model && model->haveWatchOnly())
- writer.addColumn(tr("Watchonly"), TransactionTableModel::Watchonly);
+ writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);
writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 2a9ac4650f..00a011d937 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -59,24 +59,20 @@ public:
static const int CURRENT_VERSION = 1;
int nVersion;
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
- SendCoinsRecipient* pthis = const_cast<SendCoinsRecipient*>(this);
-
- std::string sAddress = pthis->address.toStdString();
- std::string sLabel = pthis->label.toStdString();
- std::string sMessage = pthis->message.toStdString();
+ std::string sAddress = address.toStdString();
+ std::string sLabel = label.toStdString();
+ std::string sMessage = message.toStdString();
std::string sPaymentRequest;
- if (!fRead && pthis->paymentRequest.IsInitialized())
- pthis->paymentRequest.SerializeToString(&sPaymentRequest);
- std::string sAuthenticatedMerchant = pthis->authenticatedMerchant.toStdString();
+ if (!ser_action.ForRead() && paymentRequest.IsInitialized())
+ paymentRequest.SerializeToString(&sPaymentRequest);
+ std::string sAuthenticatedMerchant = authenticatedMerchant.toStdString();
- READWRITE(pthis->nVersion);
- nVersion = pthis->nVersion;
+ READWRITE(this->nVersion);
+ nVersion = this->nVersion;
READWRITE(sAddress);
READWRITE(sLabel);
READWRITE(amount);
@@ -84,14 +80,14 @@ public:
READWRITE(sPaymentRequest);
READWRITE(sAuthenticatedMerchant);
- if (fRead)
+ if (ser_action.ForRead())
{
- pthis->address = QString::fromStdString(sAddress);
- pthis->label = QString::fromStdString(sLabel);
- pthis->message = QString::fromStdString(sMessage);
+ address = QString::fromStdString(sAddress);
+ label = QString::fromStdString(sLabel);
+ message = QString::fromStdString(sMessage);
if (!sPaymentRequest.empty())
- pthis->paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size()));
- pthis->authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant);
+ paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size()));
+ authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant);
}
}
};
@@ -260,7 +256,7 @@ public slots:
void updateTransaction(const QString &hash, int status);
/* New, updated or removed address book entry */
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status);
- /* Watchonly added */
+ /* Watch-only added */
void updateWatchOnlyFlag(bool fHaveWatchonly);
/* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */
void pollBalanceChanged();
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 83fe629351..4b3beae20c 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -392,7 +392,7 @@ Value gettxout(const Array& params, bool fHelp)
if (n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull())
return Value::null;
- std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
+ BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
CBlockIndex *pindex = it->second;
ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex()));
if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT)
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index 7cd704193d..a73641834d 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -88,7 +88,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
if (hashBlock != 0) {
entry.push_back(Pair("blockhash", hashBlock.GetHex()));
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
+ BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 215da2ea12..100d6c2bd0 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1447,7 +1447,7 @@ Value listsinceblock(const Array& params, bool fHelp)
uint256 blockId = 0;
blockId.SetHex(params[0].get_str());
- std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId);
+ BlockMap::iterator it = mapBlockIndex.find(blockId);
if (it != mapBlockIndex.end())
pindex = it->second;
}
diff --git a/src/serialize.h b/src/serialize.h
index 1440676a16..dba3460d1b 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -91,9 +91,9 @@ enum
/* Implement three methods for serializable objects. These are actually wrappers over
* "SerializationOp" template, which implements the body of each class' serialization
- * code. Adding "IMPLEMENT_SERIALIZE" in the body of the class causes these wrappers to be
+ * code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be
* added as members. */
-#define IMPLEMENT_SERIALIZE \
+#define ADD_SERIALIZE_METHODS \
size_t GetSerializeSize(int nType, int nVersion) const { \
CSizeComputer s(nType, nVersion); \
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion);\
@@ -807,7 +807,7 @@ void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion)
//
-// Support for IMPLEMENT_SERIALIZE and READWRITE macro
+// Support for ADD_SERIALIZE_METHODS and READWRITE macro
//
struct CSerActionSerialize
{
diff --git a/src/uint256.h b/src/uint256.h
index d1a822af0d..6bb9a59400 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -10,6 +10,7 @@
#include <stdexcept>
#include <stdint.h>
#include <string>
+#include <cstring>
#include <vector>
class uint_error : public std::runtime_error {
@@ -215,8 +216,8 @@ public:
friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
- friend inline bool operator==(const base_uint& a, const base_uint& b) { return a.CompareTo(b) == 0; }
- friend inline bool operator!=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) != 0; }
+ friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
+ friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }
friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; }
friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; }
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 18a5b3971c..d3ad4869bb 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -2113,7 +2113,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) {
// iterate over all wallet transactions...
const CWalletTx &wtx = (*it).second;
- std::map<uint256, CBlockIndex*>::const_iterator blit = mapBlockIndex.find(wtx.hashBlock);
+ BlockMap::const_iterator blit = mapBlockIndex.find(wtx.hashBlock);
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) {
// ... which are already in a block
int nHeight = blit->second->nHeight;
@@ -2233,7 +2233,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
}
// Is the tx in a block that's in the main chain
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
+ BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end())
return 0;
CBlockIndex* pindex = (*mi).second;
@@ -2250,7 +2250,7 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const
AssertLockHeld(cs_main);
// Find the block it claims to be in
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
+ BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end())
return 0;
CBlockIndex* pindex = (*mi).second;
diff --git a/src/wallet.h b/src/wallet.h
index cea61afed3..f8e1ebac12 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -64,7 +64,7 @@ public:
CKeyPool();
CKeyPool(const CPubKey& vchPubKeyIn);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -492,7 +492,7 @@ public:
fMerkleVerified = false;
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -605,25 +605,22 @@ public:
nOrderPos = -1;
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
- CWalletTx* pthis = const_cast<CWalletTx*>(this);
- if (fRead)
- pthis->Init(NULL);
+ if (ser_action.ForRead())
+ Init(NULL);
char fSpent = false;
- if (!fRead)
+ if (!ser_action.ForRead())
{
- pthis->mapValue["fromaccount"] = pthis->strFromAccount;
+ mapValue["fromaccount"] = strFromAccount;
- WriteOrderPos(pthis->nOrderPos, pthis->mapValue);
+ WriteOrderPos(nOrderPos, mapValue);
if (nTimeSmart)
- pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart);
+ mapValue["timesmart"] = strprintf("%u", nTimeSmart);
}
READWRITE(*(CMerkleTx*)this);
@@ -636,13 +633,13 @@ public:
READWRITE(fFromMe);
READWRITE(fSpent);
- if (fRead)
+ if (ser_action.ForRead())
{
- pthis->strFromAccount = pthis->mapValue["fromaccount"];
+ strFromAccount = mapValue["fromaccount"];
- ReadOrderPos(pthis->nOrderPos, pthis->mapValue);
+ ReadOrderPos(nOrderPos, mapValue);
- pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0;
+ nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
}
mapValue.erase("fromaccount");
@@ -896,7 +893,7 @@ public:
CWalletKey(int64_t nExpires=0);
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -932,7 +929,7 @@ public:
vchPubKey = CPubKey();
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
@@ -975,13 +972,10 @@ public:
nEntryNo = 0;
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- bool fRead = ser_action.ForRead();
-
- CAccountingEntry& me = *const_cast<CAccountingEntry*>(this);
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
// Note: strAccount is serialized as part of the key, not here.
@@ -989,9 +983,9 @@ public:
READWRITE(nTime);
READWRITE(LIMITED_STRING(strOtherAccount, 65536));
- if (!fRead)
+ if (!ser_action.ForRead())
{
- WriteOrderPos(nOrderPos, me.mapValue);
+ WriteOrderPos(nOrderPos, mapValue);
if (!(mapValue.empty() && _ssExtra.empty()))
{
@@ -999,26 +993,26 @@ public:
ss.insert(ss.begin(), '\0');
ss << mapValue;
ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end());
- me.strComment.append(ss.str());
+ strComment.append(ss.str());
}
}
READWRITE(LIMITED_STRING(strComment, 65536));
size_t nSepPos = strComment.find("\0", 0, 1);
- if (fRead)
+ if (ser_action.ForRead())
{
- me.mapValue.clear();
+ mapValue.clear();
if (std::string::npos != nSepPos)
{
CDataStream ss(std::vector<char>(strComment.begin() + nSepPos + 1, strComment.end()), nType, nVersion);
- ss >> me.mapValue;
- me._ssExtra = std::vector<char>(ss.begin(), ss.end());
+ ss >> mapValue;
+ _ssExtra = std::vector<char>(ss.begin(), ss.end());
}
- ReadOrderPos(me.nOrderPos, me.mapValue);
+ ReadOrderPos(nOrderPos, mapValue);
}
if (std::string::npos != nSepPos)
- me.strComment.erase(nSepPos);
+ strComment.erase(nSepPos);
mapValue.erase("n");
}
diff --git a/src/walletdb.h b/src/walletdb.h
index cf1a66216e..ce63bb0b97 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -55,7 +55,7 @@ public:
nCreateTime = nCreateTime_;
}
- IMPLEMENT_SERIALIZE;
+ ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {