Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Nru bitcoinunlimited-1.0.1.1/configure.ac bitcoinunlimited-1.0.1.2/configure.ac
- --- bitcoinunlimited-1.0.1.1/configure.ac 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/configure.ac 2017-03-21 23:57:43.000000000 +0000
- @@ -12,7 +12,7 @@
- define(_CLIENT_VERSION_MAJOR, 1)
- define(_CLIENT_VERSION_MINOR, 0)
- define(_CLIENT_VERSION_REVISION, 1)
- -define(_CLIENT_VERSION_BUILD, 1)
- +define(_CLIENT_VERSION_BUILD, 2)
- define(_CLIENT_VERSION_IS_RELEASE, true)
- define(_COPYRIGHT_YEAR, 2017)
- AC_INIT([Bitcoin Unlimited],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/BitcoinUnlimited/BitcoinUnlimited/issues],[bitcoinUnlimited])
- diff -Nru bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-arm.yml bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-arm.yml
- --- bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-arm.yml 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-arm.yml 2017-03-21 23:57:43.000000000 +0000
- @@ -1,5 +1,5 @@
- ---
- -name: "BitcoinUnlimited-linux-0.12"
- +name: "BitcoinUnlimited-linux-1.0"
- enable_cache: true
- suites:
- - "trusty"
- diff -Nru bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-linux.yml bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-linux.yml
- --- bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-linux.yml 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-linux.yml 2017-03-21 23:57:43.000000000 +0000
- @@ -1,5 +1,5 @@
- ---
- -name: "BitcoinUnlimited-linux-0.12"
- +name: "BitcoinUnlimited-linux-1.0"
- enable_cache: true
- suites:
- - "trusty"
- diff -Nru bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-osx.yml bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-osx.yml
- --- bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-osx.yml 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-osx.yml 2017-03-21 23:57:43.000000000 +0000
- @@ -1,5 +1,5 @@
- ---
- -name: "BitcoinUnlimited-osx-0.12.1"
- +name: "BitcoinUnlimited-osx-1.0"
- enable_cache: true
- suites:
- - "trusty"
- diff -Nru bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-win.yml bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-win.yml
- --- bitcoinunlimited-1.0.1.1/contrib/gitian-descriptors/gitian-win.yml 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/contrib/gitian-descriptors/gitian-win.yml 2017-03-21 23:57:43.000000000 +0000
- @@ -1,5 +1,5 @@
- ---
- -name: "BitcoinUnlimited-win-0.12"
- +name: "BitcoinUnlimited-win-1.0"
- enable_cache: true
- suites:
- - "trusty"
- diff -Nru bitcoinunlimited-1.0.1.1/debian/changelog bitcoinunlimited-1.0.1.2/debian/changelog
- --- bitcoinunlimited-1.0.1.1/debian/changelog 2017-03-14 22:31:00.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/debian/changelog 2017-03-22 00:08:57.000000000 +0000
- @@ -1,5 +1,5 @@
- -bitcoinunlimited (1.0.1.1-yakkety) yakkety; urgency=medium
- +bitcoinunlimited (1.0.1.2-yakkety) yakkety; urgency=medium
- - * Bitcoin Unlimited 1.0.1.1 release
- + * Bitcoin Unlimited 1.0.1.2 release
- - -- Andrea Suisani (sickpig) <sickpig@gmail.com> Fri, 14 Mar 2017 23:31:00 +0100
- + -- Andrea Suisani (sickpig) <sickpig@gmail.com> Fri, 22 Mar 2017 01:09:00 +0100
- diff -Nru bitcoinunlimited-1.0.1.1/debian/rules bitcoinunlimited-1.0.1.2/debian/rules
- --- bitcoinunlimited-1.0.1.1/debian/rules 2017-03-10 16:54:25.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/debian/rules 2017-03-21 23:59:55.000000000 +0000
- @@ -18,7 +18,7 @@
- # Yea, autogen should be run on the source archive, but I like doing git archive
- override_dh_auto_configure:
- ./autogen.sh
- - LIBS="-lboost_atomic" ./configure --without-miniupnpc --with-gui=qt4
- + LIBS="-lboost_atomic" ./configure --disable-tests --without-miniupnpc --with-gui=qt4
- override_dh_auto_test:
- echo "no make check"
- diff -Nru bitcoinunlimited-1.0.1.1/doc/release-notes/release-notes-1.0.1.1.md bitcoinunlimited-1.0.1.2/doc/release-notes/release-notes-1.0.1.1.md
- --- bitcoinunlimited-1.0.1.1/doc/release-notes/release-notes-1.0.1.1.md 1970-01-01 00:00:00.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/doc/release-notes/release-notes-1.0.1.1.md 2017-03-21 23:57:43.000000000 +0000
- @@ -0,0 +1,36 @@
- +Release Notes for Bitcoin Unlimited v1.0.1.1
- +==========================================
- +
- +Bitcoin Unlimited version 1.0.1.1 is now available from:
- +
- + <https://bitcoinunlimited.info/download>
- +
- +Please report bugs using the issue tracker at github:
- +
- + <https://github.com/BitcoinUnlimited/BitcoinUnlimited/issues>
- +
- +This is an hotfix release.
- +
- +Upgrading
- +---------
- +
- +If you are running an older version, shut it down. Wait until it has completely
- +shut down (which might take a few minutes for older versions), then run the
- +installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or
- +bitcoind/bitcoin-qt (on Linux).
- +
- +Main Changes
- +------------
- +
- +Changes are as follows:
- +
- +- Fix unwanted assertion Sending an invalid GET_XTHIN is a serious misbehavior and any node doing so will be DOS100 banned immediately. Also sending a GET_XTHIN with an invalid message type will also cause the sendder to be banned. This bug cause the node to crash.
- +- Fix pruning when syncing a chain for the first time. iWhen syncing a chain with pruning enabled there are at times new blocks arriving which make the nLastHeight equal to the tip of the blockchain, however this prevents block files from being removed during pruning. By not downloading new blocks until the chain no longer in IsInitialDownload() the issue is prevented.
- +
- +Commit details
- +--------------
- +- `95c594a` version 1.0.1.1 (Andrew Stone)
- +- `eee6a2d` Fix potential unwanted assertion (Peter Tschipper)
- +- `db93b0c` Merge pull request #291 from ptschip/dev_prune (gandrewstone)
- +- `b200b0d` Bump client version (Justaphf)
- +- `da4619d` Merge pull request #300 from Justaphf/dev_2017 (gandrewstone)
- diff -Nru bitcoinunlimited-1.0.1.1/.git/config bitcoinunlimited-1.0.1.2/.git/config
- --- bitcoinunlimited-1.0.1.1/.git/config 2017-03-14 22:18:43.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/.git/config 2017-03-21 23:57:40.000000000 +0000
- @@ -4,5 +4,5 @@
- bare = false
- logallrefupdates = true
- [remote "origin"]
- - url = https://github.com/bitcoinUnlimited/BitcoinUnlimited.git
- - fetch = +refs/tags/1.0.1.1:refs/tags/1.0.1.1
- + url = git@github.com:BitcoinUnlimited/BUprivate.git
- + fetch = +refs/tags/1.0.1.2:refs/tags/1.0.1.2
- diff -Nru bitcoinunlimited-1.0.1.1/.git/HEAD bitcoinunlimited-1.0.1.2/.git/HEAD
- --- bitcoinunlimited-1.0.1.1/.git/HEAD 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/.git/HEAD 2017-03-21 23:57:43.000000000 +0000
- @@ -1 +1 @@
- -95c594ade707e49639cda33845dbfaee9ba86acd
- +a73f2b336742b25af69c6030683f3dbd5438778a
- Binary files /tmp/tmpReIBYD/qrqmSo2qWE/bitcoinunlimited-1.0.1.1/.git/index and /tmp/tmpReIBYD/et8aYIiQbc/bitcoinunlimited-1.0.1.2/.git/index differ
- diff -Nru bitcoinunlimited-1.0.1.1/.git/logs/HEAD bitcoinunlimited-1.0.1.2/.git/logs/HEAD
- --- bitcoinunlimited-1.0.1.1/.git/logs/HEAD 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/.git/logs/HEAD 2017-03-21 23:57:43.000000000 +0000
- @@ -1 +1 @@
- -0000000000000000000000000000000000000000 95c594ade707e49639cda33845dbfaee9ba86acd Andrea Suisani <sickpig@gmail.com> 1489529927 +0100 clone: from https://github.com/bitcoinUnlimited/BitcoinUnlimited.git
- +0000000000000000000000000000000000000000 a73f2b336742b25af69c6030683f3dbd5438778a Andrea Suisani <sickpig@gmail.com> 1490140663 +0100 clone: from git@github.com:BitcoinUnlimited/BUprivate.git
- Binary files /tmp/tmpReIBYD/qrqmSo2qWE/bitcoinunlimited-1.0.1.1/.git/objects/pack/pack-6789b15c8e3b7de4b2fda24e7e28d1e798091cf8.idx and /tmp/tmpReIBYD/et8aYIiQbc/bitcoinunlimited-1.0.1.2/.git/objects/pack/pack-6789b15c8e3b7de4b2fda24e7e28d1e798091cf8.idx differ
- Binary files /tmp/tmpReIBYD/qrqmSo2qWE/bitcoinunlimited-1.0.1.1/.git/objects/pack/pack-6789b15c8e3b7de4b2fda24e7e28d1e798091cf8.pack and /tmp/tmpReIBYD/et8aYIiQbc/bitcoinunlimited-1.0.1.2/.git/objects/pack/pack-6789b15c8e3b7de4b2fda24e7e28d1e798091cf8.pack differ
- Binary files /tmp/tmpReIBYD/qrqmSo2qWE/bitcoinunlimited-1.0.1.1/.git/objects/pack/pack-d3c99a09174070093781eafb7547ec30caf62ba5.idx and /tmp/tmpReIBYD/et8aYIiQbc/bitcoinunlimited-1.0.1.2/.git/objects/pack/pack-d3c99a09174070093781eafb7547ec30caf62ba5.idx differ
- Binary files /tmp/tmpReIBYD/qrqmSo2qWE/bitcoinunlimited-1.0.1.1/.git/objects/pack/pack-d3c99a09174070093781eafb7547ec30caf62ba5.pack and /tmp/tmpReIBYD/et8aYIiQbc/bitcoinunlimited-1.0.1.2/.git/objects/pack/pack-d3c99a09174070093781eafb7547ec30caf62ba5.pack differ
- diff -Nru bitcoinunlimited-1.0.1.1/.git/packed-refs bitcoinunlimited-1.0.1.2/.git/packed-refs
- --- bitcoinunlimited-1.0.1.1/.git/packed-refs 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/.git/packed-refs 2017-03-21 23:57:43.000000000 +0000
- @@ -1,2 +1,2 @@
- # pack-refs with: peeled fully-peeled
- -95c594ade707e49639cda33845dbfaee9ba86acd refs/tags/1.0.1.1
- +a73f2b336742b25af69c6030683f3dbd5438778a refs/tags/1.0.1.2
- diff -Nru bitcoinunlimited-1.0.1.1/.git/shallow bitcoinunlimited-1.0.1.2/.git/shallow
- --- bitcoinunlimited-1.0.1.1/.git/shallow 2017-03-14 22:18:44.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/.git/shallow 2017-03-21 23:57:40.000000000 +0000
- @@ -1 +1 @@
- -95c594ade707e49639cda33845dbfaee9ba86acd
- +a73f2b336742b25af69c6030683f3dbd5438778a
- diff -Nru bitcoinunlimited-1.0.1.1/qa/rpc-tests/txn_clone.py bitcoinunlimited-1.0.1.2/qa/rpc-tests/txn_clone.py
- --- bitcoinunlimited-1.0.1.1/qa/rpc-tests/txn_clone.py 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/qa/rpc-tests/txn_clone.py 2017-03-21 23:57:43.000000000 +0000
- @@ -25,6 +25,7 @@
- # All nodes should start with 1,250 BTC:
- starting_balance = 1250
- for i in range(4):
- + print("node ", i," balance ", self.nodes[i].getbalance())
- assert_equal(self.nodes[i].getbalance(), starting_balance)
- self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
- diff -Nru bitcoinunlimited-1.0.1.1/qa/rpc-tests/txn_doublespend.py bitcoinunlimited-1.0.1.2/qa/rpc-tests/txn_doublespend.py
- --- bitcoinunlimited-1.0.1.1/qa/rpc-tests/txn_doublespend.py 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/qa/rpc-tests/txn_doublespend.py 2017-03-21 23:57:43.000000000 +0000
- @@ -25,6 +25,7 @@
- # All nodes should start with 1,250 BTC:
- starting_balance = 1250
- for i in range(4):
- + print("node ", i," balance ", self.nodes[i].getbalance())
- assert_equal(self.nodes[i].getbalance(), starting_balance)
- self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
- diff -Nru bitcoinunlimited-1.0.1.1/src/addrman.cpp bitcoinunlimited-1.0.1.2/src/addrman.cpp
- --- bitcoinunlimited-1.0.1.1/src/addrman.cpp 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/addrman.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -118,7 +118,7 @@
- void CAddrMan::Delete(int nId)
- {
- - assert(mapInfo.count(nId) != 0);
- + DbgAssert(mapInfo.count(nId) != 0, return); // already deleted so no-op
- CAddrInfo& info = mapInfo[nId];
- assert(!info.fInTried);
- assert(info.nRefCount == 0);
- diff -Nru bitcoinunlimited-1.0.1.1/src/chain.h bitcoinunlimited-1.0.1.2/src/chain.h
- --- bitcoinunlimited-1.0.1.1/src/chain.h 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/chain.h 2017-03-21 23:57:43.000000000 +0000
- @@ -378,6 +378,7 @@
- /** Efficiently check whether a block is present in this chain. */
- bool Contains(const CBlockIndex *pindex) const {
- + if (!pindex) return false; // null pointer isn't in this chain
- return (*this)[pindex->nHeight] == pindex;
- }
- diff -Nru bitcoinunlimited-1.0.1.1/src/clientversion.cpp bitcoinunlimited-1.0.1.2/src/clientversion.cpp
- --- bitcoinunlimited-1.0.1.1/src/clientversion.cpp 2017-03-14 22:26:20.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/clientversion.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -105,7 +105,7 @@
- std::string FormatFullVersion()
- {
- - return "1.0.1.1-95c594a";
- + return CLIENT_BUILD;
- }
- /**
- diff -Nru bitcoinunlimited-1.0.1.1/src/clientversion.h bitcoinunlimited-1.0.1.2/src/clientversion.h
- --- bitcoinunlimited-1.0.1.1/src/clientversion.h 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/clientversion.h 2017-03-21 23:57:43.000000000 +0000
- @@ -18,7 +18,7 @@
- #define CLIENT_VERSION_MAJOR 1
- #define CLIENT_VERSION_MINOR 0
- #define CLIENT_VERSION_REVISION 1
- -#define CLIENT_VERSION_BUILD 1
- +#define CLIENT_VERSION_BUILD 2
- //! Set to true for release, false for prerelease or test build
- #define CLIENT_VERSION_IS_RELEASE true
- diff -Nru bitcoinunlimited-1.0.1.1/src/main.cpp bitcoinunlimited-1.0.1.2/src/main.cpp
- --- bitcoinunlimited-1.0.1.1/src/main.cpp 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/main.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -365,15 +365,15 @@
- //EraseOrphansFor(nodeid); BUIP010 Xtreme Thinblocks - We do not want to delete orphans at any time. We handle them when we accept a block
- nPreferredDownload -= state->fPreferredDownload;
- nPeersWithValidatedDownloads -= (state->nBlocksInFlightValidHeaders != 0);
- - assert(nPeersWithValidatedDownloads >= 0);
- + DbgAssert(nPeersWithValidatedDownloads >= 0, nPeersWithValidatedDownloads=0);
- mapNodeState.erase(nodeid);
- if (mapNodeState.empty()) {
- - // Do a consistency check after the last peer is removed.
- - assert(mapBlocksInFlight.empty());
- - assert(nPreferredDownload == 0);
- - assert(nPeersWithValidatedDownloads == 0);
- + // Do a consistency check after the last peer is removed. Force consistent state if production code
- + DbgAssert(mapBlocksInFlight.empty(), mapBlocksInFlight.clear());
- + DbgAssert(nPreferredDownload == 0, nPreferredDownload = 0);
- + DbgAssert(nPeersWithValidatedDownloads == 0, nPeersWithValidatedDownloads = 0);
- }
- }
- @@ -475,7 +475,7 @@
- /** Check whether the last unknown block a peer advertised is not yet known. */
- void ProcessBlockAvailability(NodeId nodeid) {
- CNodeState *state = State(nodeid);
- - assert(state != NULL);
- + DbgAssert(state != NULL, return); // node already destructed, nothing to do in production mode
- if (!state->hashLastUnknownBlock.IsNull()) {
- BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock);
- @@ -490,7 +490,7 @@
- /** Update tracking information about which blocks a peer is assumed to have. */
- void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
- CNodeState *state = State(nodeid);
- - assert(state != NULL);
- + DbgAssert(state != NULL, return); // node already destructed, nothing to do in production mode
- ProcessBlockAvailability(nodeid);
- @@ -542,7 +542,7 @@
- vBlocks.reserve(vBlocks.size() + count);
- CNodeState *state = State(nodeid);
- - assert(state != NULL);
- + DbgAssert(state != NULL, return);
- // Make sure pindexBestKnownBlock is up to date, we'll need it.
- ProcessBlockAvailability(nodeid);
- @@ -622,8 +622,8 @@
- -// Requires cs_main.
- void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, CBlockIndex *pindex = NULL) {
- + AssertLockHeld(cs_main);
- CNodeState *state = State(nodeid);
- assert(state != NULL);
- @@ -2026,8 +2026,18 @@
- int GetSpendHeight(const CCoinsViewCache& inputs)
- {
- LOCK(cs_main);
- - CBlockIndex* pindexPrev = mapBlockIndex.find(inputs.GetBestBlock())->second;
- - return pindexPrev->nHeight + 1;
- + BlockMap::iterator i = mapBlockIndex.find(inputs.GetBestBlock());
- + if (i != mapBlockIndex.end())
- + {
- + CBlockIndex* pindexPrev = i->second;
- + if (pindexPrev)
- + return pindexPrev->nHeight + 1;
- + else
- + {
- + throw runtime_error("GetSpendHeight(): mapBlockIndex contains null block");
- + }
- + }
- + throw runtime_error("GetSpendHeight(): best block does not exist");
- }
- namespace Consensus {
- @@ -3704,10 +3714,10 @@
- AssertLockHeld(cs_main);
- // Check for duplicate
- uint256 hash = block.GetHash();
- - BlockMap::iterator miSelf = mapBlockIndex.find(hash);
- CBlockIndex *pindex = NULL;
- - if (hash != chainparams.GetConsensus().hashGenesisBlock) {
- -
- + if (hash != chainparams.GetConsensus().hashGenesisBlock)
- + {
- + BlockMap::iterator miSelf = mapBlockIndex.find(hash);
- if (miSelf != mapBlockIndex.end()) {
- // Block header is already known.
- pindex = miSelf->second;
- @@ -4769,7 +4779,7 @@
- {
- case MSG_TX:
- {
- - assert(recentRejects);
- + // remove assertions from P2P code, but this should hold: assert(recentRejects);
- if (chainActive.Tip()->GetBlockHash() != hashRecentRejectsChainTip)
- {
- // If the chain tip has changed previously rejected transactions
- @@ -4777,9 +4787,11 @@
- // or a double-spend. Reset the rejects filter and give those
- // txs a second chance.
- hashRecentRejectsChainTip = chainActive.Tip()->GetBlockHash();
- - recentRejects->reset();
- + if (recentRejects) recentRejects->reset();
- + else recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
- }
- - return recentRejects->contains(inv.hash) ||
- + bool rrc = recentRejects ? recentRejects->contains(inv.hash) : false;
- + return rrc ||
- mempool.exists(inv.hash) ||
- AlreadyHaveOrphan(inv.hash) ||
- pcoinsTip->HaveCoins(inv.hash);
- @@ -4850,61 +4862,68 @@
- // Pruned nodes may have deleted the block, so check whether
- // it's available before trying to send.
- if (send && (mi->second->nStatus & BLOCK_HAVE_DATA))
- - {
- + {
- // Send block from disk
- CBlock block;
- if (!ReadBlockFromDisk(block, (*mi).second, consensusParams))
- - assert(!"cannot load block from disk");
- - if (inv.type == MSG_BLOCK)
- - {
- - pfrom->blocksSent += 1;
- - pfrom->PushMessage(NetMsgType::BLOCK, block);
- - }
- -
- - // BUIP010 Xtreme Thinblocks: begin section
- - else if (inv.type == MSG_THINBLOCK || inv.type == MSG_XTHINBLOCK) {
- - LogPrint("thin", "Sending xthin by INV queue getdata message\n");
- - SendXThinBlock(block, pfrom, inv);
- - }
- - // BUIP010 Xtreme Thinblocks: end section
- -
- - else // MSG_FILTERED_BLOCK)
- - {
- - LOCK(pfrom->cs_filter);
- - if (pfrom->pfilter)
- - {
- - CMerkleBlock merkleBlock(block, *pfrom->pfilter);
- - pfrom->PushMessage(NetMsgType::MERKLEBLOCK, merkleBlock);
- + {
- + // its possible that I know about it but haven't stored it yet
- + LogPrint("thin", "unable to load block %s from disk\n", (*mi).second->phashBlock ? (*mi).second->phashBlock->ToString() : "");
- + // no response
- + }
- + else
- + {
- + if (inv.type == MSG_BLOCK)
- + {
- pfrom->blocksSent += 1;
- - // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
- - // This avoids hurting performance by pointlessly requiring a round-trip
- - // Note that there is currently no way for a node to request any single transactions we didn't send here -
- - // they must either disconnect and retry or request the full block.
- - // Thus, the protocol spec specified allows for us to provide duplicate txn here,
- - // however we MUST always provide at least what the remote peer needs
- - typedef std::pair<unsigned int, uint256> PairType;
- - BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
- - {
- - pfrom->txsSent += 1;
- - pfrom->PushMessage(NetMsgType::TX, block.vtx[pair.first]);
- - }
- + pfrom->PushMessage(NetMsgType::BLOCK, block);
- + }
- +
- + // BUIP010 Xtreme Thinblocks: begin section
- + else if (inv.type == MSG_THINBLOCK || inv.type == MSG_XTHINBLOCK) {
- + LogPrint("thin", "Sending xthin by INV queue getdata message\n");
- + SendXThinBlock(block, pfrom, inv);
- }
- - // else
- + // BUIP010 Xtreme Thinblocks: end section
- +
- + else // MSG_FILTERED_BLOCK)
- + {
- + LOCK(pfrom->cs_filter);
- + if (pfrom->pfilter)
- + {
- + CMerkleBlock merkleBlock(block, *pfrom->pfilter);
- + pfrom->PushMessage(NetMsgType::MERKLEBLOCK, merkleBlock);
- + pfrom->blocksSent += 1;
- + // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
- + // This avoids hurting performance by pointlessly requiring a round-trip
- + // Note that there is currently no way for a node to request any single transactions we didn't send here -
- + // they must either disconnect and retry or request the full block.
- + // Thus, the protocol spec specified allows for us to provide duplicate txn here,
- + // however we MUST always provide at least what the remote peer needs
- + typedef std::pair<unsigned int, uint256> PairType;
- + BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
- + {
- + pfrom->txsSent += 1;
- + pfrom->PushMessage(NetMsgType::TX, block.vtx[pair.first]);
- + }
- + }
- + // else
- // no response
- - }
- + }
- - // Trigger the peer node to send a getblocks request for the next batch of inventory
- - if (inv.hash == pfrom->hashContinue)
- - {
- - // Bypass PushInventory, this must send even if redundant,
- - // and we want it right after the last block so they don't
- - // wait for other stuff first.
- - vector<CInv> vInv;
- - vInv.push_back(CInv(MSG_BLOCK, chainActive.Tip()->GetBlockHash()));
- - pfrom->PushMessage(NetMsgType::INV, vInv);
- - pfrom->hashContinue.SetNull();
- - }
- - }
- + // Trigger the peer node to send a getblocks request for the next batch of inventory
- + if (inv.hash == pfrom->hashContinue)
- + {
- + // Bypass PushInventory, this must send even if redundant,
- + // and we want it right after the last block so they don't
- + // wait for other stuff first.
- + vector<CInv> vInv;
- + vInv.push_back(CInv(MSG_BLOCK, chainActive.Tip()->GetBlockHash()));
- + pfrom->PushMessage(NetMsgType::INV, vInv);
- + pfrom->hashContinue.SetNull();
- + }
- + }
- + }
- }
- else if (inv.IsKnownType())
- {
- @@ -5238,12 +5257,23 @@
- {
- vector<CInv> vInv;
- vRecv >> vInv;
- - if (vInv.size() > MAX_INV_SZ)
- + if ((vInv.size() > MAX_INV_SZ)||(vInv.size() == 0)) // BU check size == 0 to be intolerant of an empty and useless request
- {
- Misbehaving(pfrom->GetId(), 20);
- return error("message inv size() = %u", vInv.size());
- }
- -
- +
- + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) // Validate that INVs are a valid type
- + {
- + const CInv &inv = vInv[nInv];
- + if (!((inv.type == MSG_TX) || (inv.type == MSG_BLOCK)))
- + {
- + Misbehaving(pfrom->GetId(), 20);
- + return error("message inv invalid type = %u", inv.type);
- + }
- + // inv.hash does not need validation, since SHA2556 hash can be any value
- + }
- +
- bool fBlocksOnly = GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
- // Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true
- @@ -5252,7 +5282,7 @@
- LOCK(cs_main);
- - std::vector<CInv> vToFetch;
- + // BU remove, unused std::vector<CInv> vToFetch;
- for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
- {
- @@ -5292,8 +5322,8 @@
- }
- }
- - if (!vToFetch.empty())
- - pfrom->PushMessage(NetMsgType::GETDATA, vToFetch);
- + // BU remove, unused if (!vToFetch.empty())
- + // BU remove, unused pfrom->PushMessage(NetMsgType::GETDATA, vToFetch);
- }
- @@ -5301,11 +5331,22 @@
- {
- vector<CInv> vInv;
- vRecv >> vInv;
- - if (vInv.size() > MAX_INV_SZ)
- + if ((vInv.size() > MAX_INV_SZ)||(vInv.size() == 0)) // BU check size == 0 to be intolerant of an empty and useless request
- {
- Misbehaving(pfrom->GetId(), 20);
- return error("message getdata size() = %u", vInv.size());
- }
- + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) // Validate that INVs are a valid type
- + {
- + const CInv &inv = vInv[nInv];
- + if (!((inv.type == MSG_TX) || (inv.type == MSG_BLOCK) || (inv.type == MSG_FILTERED_BLOCK) || (inv.type == MSG_THINBLOCK) || (inv.type == MSG_XTHINBLOCK)))
- + {
- + Misbehaving(pfrom->GetId(), 20);
- + return error("message inv invalid type = %u", inv.type);
- + }
- + // inv.hash does not need validation, since SHA2556 hash can be any value
- + }
- +
- if (fDebug || (vInv.size() != 1))
- LogPrint("net", "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id);
- @@ -5441,7 +5482,6 @@
- // Check for recently rejected (and do other quick existence checks)
- if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
- {
- -
- mempool.check(pcoinsTip);
- RelayTransaction(tx);
- vWorkQueue.push_back(inv.hash);
- @@ -5496,8 +5536,7 @@
- // Probably non-standard or insufficient fee/priority
- LogPrint("mempool", " removed orphan tx %s\n", orphanHash.ToString());
- vEraseQueue.push_back(orphanHash);
- - assert(recentRejects);
- - recentRejects->insert(orphanHash);
- + if (recentRejects) recentRejects->insert(orphanHash); // should always be true
- }
- mempool.check(pcoinsTip);
- }
- @@ -5519,8 +5558,7 @@
- if (nEvicted > 0)
- LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
- } else {
- - assert(recentRejects);
- - recentRejects->insert(tx.GetHash());
- + if (recentRejects) recentRejects->insert(tx.GetHash()); // should always be true
- if (pfrom->fWhitelisted && GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
- // Always relay transactions received from whitelisted peers, even
- @@ -5611,7 +5649,7 @@
- CNodeState *nodestate = State(pfrom->GetId());
- // If this set of headers is valid and ends in a block with at least as
- // much work as our tip, download as much as possible.
- - if (fCanDirectFetch && pindexLast->IsValid(BLOCK_VALID_TREE) && chainActive.Tip()->nChainWork <= pindexLast->nChainWork) {
- + if (fCanDirectFetch && pindexLast && pindexLast->IsValid(BLOCK_VALID_TREE) && chainActive.Tip()->nChainWork <= pindexLast->nChainWork) {
- vector<CBlockIndex *> vToFetch;
- CBlockIndex *pindexWalk = pindexLast;
- // Calculate all the blocks we'd need to switch to pindexLast, up to a limit.
- @@ -5627,7 +5665,7 @@
- // very large reorg at a time we think we're close to caught up to
- // the main chain -- this shouldn't really happen. Bail out on the
- // direct fetch and rely on parallel download instead.
- - if (!chainActive.Contains(pindexWalk)) {
- + if (pindexWalk && !chainActive.Contains(pindexWalk)) {
- LogPrint("net", "Large reorg, won't direct fetch to %s (%d)\n",
- pindexLast->GetBlockHash().ToString(),
- pindexLast->nHeight);
- @@ -5640,6 +5678,7 @@
- // Can't download any more from this peer
- break;
- }
- + // pindex must be nonnull because we populated vToFetch a few lines above
- vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
- MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), chainparams.GetConsensus(), pindex);
- LogPrint("net", "Requesting block %s from peer=%d\n",
- @@ -5689,13 +5728,20 @@
- CBloomFilter filterMemPool;
- CInv inv;
- vRecv >> inv >> filterMemPool;
- + if (!((inv.type == MSG_XTHINBLOCK)||(inv.type == MSG_THINBLOCK)))
- + {
- + Misbehaving(pfrom->GetId(), 20);
- + return error("message inv invalid type = %u", inv.type);
- + }
- +
- - LoadFilter(pfrom, &filterMemPool);
- + LoadFilter(pfrom, &filterMemPool); // Validates that the filter is reasonably sized.
- {
- LOCK(cs_main);
- BlockMap::iterator mi = mapBlockIndex.find(inv.hash);
- - if (mi == mapBlockIndex.end()) {
- + if (mi == mapBlockIndex.end()) { // This block does not even exist
- + LogPrint("thin", "Peer %s (%d) requested nonexistent block %s\n", pfrom->addrName.c_str(), pfrom->id, inv.hash.ToString());
- Misbehaving(pfrom->GetId(), 100);
- return false;
- }
- @@ -5703,9 +5749,15 @@
- CBlock block;
- const Consensus::Params& consensusParams = Params().GetConsensus();
- if (!ReadBlockFromDisk(block, (*mi).second, consensusParams))
- - assert(!"cannot load block from disk");
- -
- - SendXThinBlock(block, pfrom, inv);
- + {
- + // We don't have the block yet, although we know about it.
- + LogPrint("thin", "Peer %s (%d) requested not-yet-received block %s\n", pfrom->addrName.c_str(), pfrom->id, inv.hash.ToString());
- + return false;
- + }
- + else
- + {
- + SendXThinBlock(block, pfrom, inv);
- + }
- }
- }
- else if (strCommand == NetMsgType::XPEDITEDREQUEST) // BU
- @@ -5714,7 +5766,12 @@
- }
- else if (strCommand == NetMsgType::XPEDITEDBLK) // BU
- {
- - HandleExpeditedBlock(vRecv,pfrom);
- + if (!HandleExpeditedBlock(vRecv,pfrom))
- + {
- + LOCK(cs_main);
- + Misbehaving(pfrom->GetId(), 5);
- + return false;
- + }
- }
- // BU - used to pass BU specific version information similar to NetMsgType::VERSION
- else if (strCommand == NetMsgType::BUVERSION)
- @@ -5743,18 +5800,17 @@
- {
- CXThinBlock thinBlock;
- vRecv >> thinBlock;
- -
- + CInv inv(MSG_BLOCK, thinBlock.header.GetHash());
- // Send expedited ASAP
- CValidationState state;
- if (!CheckBlockHeader(thinBlock.header, state, true)) { // block header is bad
- - LogPrint("thin", "Thinblock %s received with bad header from peer %s (%d)\n", thinBlock.header.GetHash().ToString(), pfrom->addrName.c_str(), pfrom->id);
- + LogPrint("thin", "Thinblock %s received with bad header from peer %s (%d)\n", inv.hash.ToString(), pfrom->addrName.c_str(), pfrom->id);
- Misbehaving(pfrom->GetId(), 20);
- return false;
- }
- - else if (!IsRecentlyExpeditedAndStore(thinBlock.header.GetHash()))
- + else if (!IsRecentlyExpeditedAndStore(inv.hash))
- SendExpeditedBlock(thinBlock, 0, pfrom);
- - CInv inv(MSG_BLOCK, thinBlock.header.GetHash());
- int nSizeThinBlock = ::GetSerializeSize(thinBlock, SER_NETWORK, PROTOCOL_VERSION);
- LogPrint("thin", "Received thinblock %s from peer %s (%d). Size %d bytes.\n", inv.hash.ToString(), pfrom->addrName.c_str(), pfrom->id, nSizeThinBlock);
- @@ -5829,6 +5885,15 @@
- else if (inMissingTx)
- tx = mapMissingTx[hash];
- }
- + else
- + {
- + // Set misbehaving and abort if the thin block has a tx with a null hash.
- + LogPrintf("Misbehaving - thin block with a NULL hash\n");
- + LOCK(cs_main);
- + Misbehaving(pfrom->GetId(), 100);
- + return false;
- + }
- +
- if (tx.IsNull())
- missingCount++;
- // This will push an empty/invalid transaction if we don't have it yet
- @@ -5863,7 +5928,7 @@
- // This marks the end of the transactions we've received. If we get this and we have NOT been able to
- // finish reassembling the block, we need to re-request the full regular block:
- vector<CInv> vGetData;
- - vGetData.push_back(CInv(MSG_BLOCK, thinBlock.header.GetHash()));
- + vGetData.push_back(inv);
- pfrom->PushMessage("getdata", vGetData);
- setPreVerifiedTxHash.clear(); // Xpress Validation - clear the set since we do not do XVal on regular blocks
- LogPrint("thin", "Missing %d Thinblock transactions, re-requesting a regular block\n",
- @@ -5894,6 +5959,13 @@
- int count=0;
- size_t i;
- + if (pfrom->xThinBlockHashes.size() != pfrom->thinBlock.vtx.size()) // Because the next loop assumes this
- + {
- + LogPrint("thin", "Inconsistent thin block data. Aborting the thin block\n");
- + // TODO clear out the thin block
- + return true;
- + }
- +
- for (i = 0; i < pfrom->thinBlock.vtx.size(); i++) {
- if (pfrom->thinBlock.vtx[i].IsNull()) {
- std::map<uint64_t, CTransaction>::iterator val = mapMissingTx.find(pfrom->xThinBlockHashes[i]);
- @@ -6205,14 +6277,22 @@
- vRecv >> filter;
- if (!filter.IsWithinSizeConstraints())
- + {
- // There is no excuse for sending a too-large filter
- Misbehaving(pfrom->GetId(), 100);
- + return false;
- + }
- else
- {
- LOCK(pfrom->cs_filter);
- delete pfrom->pfilter;
- pfrom->pfilter = new CBloomFilter(filter);
- - pfrom->pfilter->UpdateEmptyFull();
- + if (!pfrom->pfilter)
- + {
- + LogPrintf("Unable to allocate new bloom filter -- out of memory");
- + return false;
- + }
- + else pfrom->pfilter->UpdateEmptyFull();
- }
- pfrom->fRelayTxes = true;
- }
- @@ -6306,9 +6386,9 @@
- }
- -// requires LOCK(cs_vRecvMsg)
- bool ProcessMessages(CNode* pfrom)
- {
- + AssertLockHeld(pfrom->cs_vRecvMsg);
- const CChainParams& chainparams = Params();
- //if (fDebug)
- // LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size());
- @@ -6591,7 +6671,7 @@
- // headers that aren't on chainActive, give up.
- BOOST_FOREACH(const uint256 &hash, pto->vBlockHashesToAnnounce) {
- BlockMap::iterator mi = mapBlockIndex.find(hash);
- - assert(mi != mapBlockIndex.end());
- + if (mi == mapBlockIndex.end()) continue; // BU skip blocks that we don't know about. was: assert(mi != mapBlockIndex.end());
- CBlockIndex *pindex = mi->second;
- if (chainActive[pindex->nHeight] != pindex) {
- // Bail out if we reorged away from this block
- @@ -6639,25 +6719,27 @@
- if (!pto->vBlockHashesToAnnounce.empty()) {
- const uint256 &hashToAnnounce = pto->vBlockHashesToAnnounce.back();
- BlockMap::iterator mi = mapBlockIndex.find(hashToAnnounce);
- - assert(mi != mapBlockIndex.end());
- - CBlockIndex *pindex = mi->second;
- -
- - // Warn if we're announcing a block that is not on the main chain.
- - // This should be very rare and could be optimized out.
- - // Just log for now.
- - if (chainActive[pindex->nHeight] != pindex) {
- - LogPrint("net", "Announcing block %s not on main chain (tip=%s)\n",
- - hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
- - }
- + if (mi != mapBlockIndex.end()) // was assert(mi != mapBlockIndex.end());
- + {
- + CBlockIndex *pindex = mi->second;
- +
- + // Warn if we're announcing a block that is not on the main chain.
- + // This should be very rare and could be optimized out.
- + // Just log for now.
- + if (chainActive[pindex->nHeight] != pindex) {
- + LogPrint("net", "Announcing block %s not on main chain (tip=%s)\n",
- + hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
- + }
- - // If the peer announced this block to us, don't inv it back.
- - // (Since block announcements may not be via inv's, we can't solely rely on
- - // setInventoryKnown to track this.)
- - if (!PeerHasHeader(&state, pindex)) {
- - pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
- - LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,
- - pto->id, hashToAnnounce.ToString());
- - }
- + // If the peer announced this block to us, don't inv it back.
- + // (Since block announcements may not be via inv's, we can't solely rely on
- + // setInventoryKnown to track this.)
- + if (!PeerHasHeader(&state, pindex)) {
- + pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
- + LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,
- + pto->id, hashToAnnounce.ToString());
- + }
- + }
- }
- } else if (!vHeaders.empty()) {
- if (vHeaders.size() > 1) {
- @@ -6752,19 +6834,9 @@
- // to unreasonably increase our timeout.
- if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0) {
- QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
- -#if 0 // TODO: original 12.0
- - int64_t nTimeoutIfRequestedNow = GetBlockTimeout(nNow, nQueuedValidatedHeaders - state.nBlocksInFlightValidHeaders, consensusParams);
- - if (queuedBlock.nTimeDisconnect > nTimeoutIfRequestedNow) {
- - LogPrint("net", "Reducing block download timeout for peer=%s (%d) block=%s, orig=%d new=%d\n", pto->addrName.c_str(), pto->id, queuedBlock.hash.ToString(), queuedBlock.nTimeDisconnect, nTimeoutIfRequestedNow);
- - queuedBlock.nTimeDisconnect = nTimeoutIfRequestedNow;
- - }
- - if (queuedBlock.nTimeDisconnect < nNow) {
- - LogPrintf("Timeout downloading block %s from peer %s (%d), disconnecting\n", queuedBlock.hash.ToString(), pto->addrName.c_str(), pto->id);
- -#else // new 12.1
- int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - (state.nBlocksInFlightValidHeaders > 0);
- if (nNow > state.nDownloadingSince + consensusParams.nPowTargetSpacing * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) {
- LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->id);
- -#endif
- pto->fDisconnect = true;
- }
- }
- diff -Nru bitcoinunlimited-1.0.1.1/src/net.cpp bitcoinunlimited-1.0.1.2/src/net.cpp
- --- bitcoinunlimited-1.0.1.1/src/net.cpp 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/net.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -1278,7 +1278,8 @@
- }
- if (fDelete) {
- vNodesDisconnected.remove(pnode);
- - assert(std::find(vNodes.begin(),vNodes.end(), pnode) == vNodes.end()); // make sure it has been removed
- + // no need to remove from vNodes. we know pnode has already been removed from vNodes since that
- + // occurred prior to insertion into vNodesDisconnected
- delete pnode;
- }
- }
- diff -Nru bitcoinunlimited-1.0.1.1/src/protocol.h bitcoinunlimited-1.0.1.2/src/protocol.h
- --- bitcoinunlimited-1.0.1.1/src/protocol.h 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/protocol.h 2017-03-21 23:57:43.000000000 +0000
- @@ -363,7 +363,7 @@
- friend bool operator<(const CInv& a, const CInv& b);
- - bool IsKnownType() const;
- + bool IsKnownType() const; // all types ever used (includes type 3 = "filtered block")
- const char* GetCommand() const;
- std::string ToString() const;
- diff -Nru bitcoinunlimited-1.0.1.1/src/rpcserver.cpp bitcoinunlimited-1.0.1.2/src/rpcserver.cpp
- --- bitcoinunlimited-1.0.1.1/src/rpcserver.cpp 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/rpcserver.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -577,7 +577,7 @@
- void RPCUnregisterTimerInterface(RPCTimerInterface *iface)
- {
- std::vector<RPCTimerInterface*>::iterator i = std::find(timerInterfaces.begin(), timerInterfaces.end(), iface);
- - assert(i != timerInterfaces.end());
- + DbgAssert(i != timerInterfaces.end(), return); // already removed, so ignore the problem in production
- timerInterfaces.erase(i);
- }
- diff -Nru bitcoinunlimited-1.0.1.1/src/script/script.h bitcoinunlimited-1.0.1.2/src/script/script.h
- --- bitcoinunlimited-1.0.1.1/src/script/script.h 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/script/script.h 2017-03-21 23:57:43.000000000 +0000
- @@ -461,7 +461,7 @@
- insert(end(), b.begin(), b.end());
- return *this;
- }
- -
- +#if 0
- CScript& operator<<(const CScript& b)
- {
- // I'm not sure if this should push the script or concatenate scripts.
- @@ -469,7 +469,7 @@
- assert(!"Warning: Pushing a CScript onto a CScript with << is probably not intended, use + to concatenate!");
- return *this;
- }
- -
- +#endif
- bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet)
- {
- diff -Nru bitcoinunlimited-1.0.1.1/src/txdb.cpp bitcoinunlimited-1.0.1.2/src/txdb.cpp
- --- bitcoinunlimited-1.0.1.1/src/txdb.cpp 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/txdb.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -103,7 +103,12 @@
- pcursor->Seek(DB_COINS);
- CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
- - stats.hashBlock = GetBestBlock();
- +
- + {
- + LOCK(cs_main);
- + stats.hashBlock = GetBestBlock();
- + stats.nHeight = mapBlockIndex.find(stats.hashBlock)->second->nHeight;
- + }
- ss << stats.hashBlock;
- CAmount nTotalAmount = 0;
- while (pcursor->Valid()) {
- @@ -132,10 +137,6 @@
- }
- pcursor->Next();
- }
- - {
- - LOCK(cs_main);
- - stats.nHeight = mapBlockIndex.find(stats.hashBlock)->second->nHeight;
- - }
- stats.hashSerialized = ss.GetHash();
- stats.nTotalAmount = nTotalAmount;
- return true;
- diff -Nru bitcoinunlimited-1.0.1.1/src/unlimited.cpp bitcoinunlimited-1.0.1.2/src/unlimited.cpp
- --- bitcoinunlimited-1.0.1.1/src/unlimited.cpp 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/unlimited.cpp 2017-03-21 23:57:43.000000000 +0000
- @@ -185,7 +185,6 @@
- void HandleExpeditedRequest(CDataStream& vRecv,CNode* pfrom)
- {
- - // TODO locks
- uint64_t options;
- vRecv >> options;
- bool stop = ((options & EXPEDITED_STOP) != 0); // Are we starting or stopping expedited service?
- @@ -210,12 +209,12 @@
- if (xpeditedBlk.size() < maxExpedited )
- {
- LogPrint("blk", "Starting expedited blocks to peer %s (%d).\n", pfrom->addrName.c_str(),pfrom->id);
- - std::vector<CNode*>::iterator it = std::find(xpeditedBlk.begin(), xpeditedBlk.end(),((CNode*)NULL));
- + std::vector<CNode*>::iterator it = std::find(xpeditedBlk.begin(), xpeditedBlk.end(),(CNode*)NULL); // find an empty array location
- if (it != xpeditedBlk.end())
- *it = pfrom;
- else
- xpeditedBlk.push_back(pfrom);
- - pfrom->AddRef();
- + pfrom->AddRef(); // add a reference because we have added this pointer into the expedited array
- }
- else
- {
- @@ -271,7 +270,7 @@
- return false;
- }
- -void HandleExpeditedBlock(CDataStream& vRecv,CNode* pfrom)
- +bool HandleExpeditedBlock(CDataStream& vRecv,CNode* pfrom)
- {
- unsigned char hops;
- unsigned char msgType;
- @@ -281,35 +280,35 @@
- {
- CXThinBlock thinBlock;
- vRecv >> thinBlock;
- + uint256 blkHash = thinBlock.header.GetHash();
- + CInv inv(MSG_BLOCK, blkHash);
- - CInv inv(MSG_BLOCK, thinBlock.header.GetHash());
- -
- - BlockMap::iterator mapEntry = mapBlockIndex.find(thinBlock.header.GetHash());
- + BlockMap::iterator mapEntry = mapBlockIndex.find(blkHash);
- CBlockIndex *blkidx = NULL;
- unsigned int status = 0;
- if (mapEntry != mapBlockIndex.end())
- {
- blkidx = mapEntry->second;
- - status = blkidx->nStatus;
- + if (blkidx) status = blkidx->nStatus;
- }
- bool newBlock = ((blkidx == NULL) || (!(blkidx->nStatus & BLOCK_HAVE_DATA))); // If I have never seen the block or just seen an INV, treat the block as new
- int nSizeThinBlock = ::GetSerializeSize(thinBlock, SER_NETWORK, PROTOCOL_VERSION); // TODO replace with size of vRecv for efficiency
- LogPrint("thin", "Received %s expedited thinblock %s from peer %s (%d). Hop %d. Size %d bytes. (status %d,0x%x)\n", newBlock ? "new":"repeated", inv.hash.ToString(), pfrom->addrName.c_str(),pfrom->id, hops, nSizeThinBlock,status,status);
- // Skip if we've already seen this block
- - // TODO move thes above the print, once we ensure no unexpected dups.
- - if (IsRecentlyExpeditedAndStore(thinBlock.header.GetHash())) return;
- + // TODO move this above the print, once we ensure no unexpected dups.
- + if (IsRecentlyExpeditedAndStore(blkHash)) return true;
- if (!newBlock)
- {
- // TODO determine if we have the block or just have an INV to it.
- - return;
- + return true;
- }
- CValidationState state;
- if (!CheckBlockHeader(thinBlock.header, state, true)) // block header is bad
- {
- - // demerit the sender
- - return;
- + // demerit the sender, it should have checked the header before expedited relay
- + return false;
- }
- // TODO: Start headers-only mining now
- @@ -319,7 +318,9 @@
- else
- {
- LogPrint("thin", "Received unknown (0x%x) expedited message from peer %s (%d). Hop %d.\n", msgType, pfrom->addrName.c_str(),pfrom->id, hops);
- + return false;
- }
- + return true;
- }
- void SendExpeditedBlock(CXThinBlock& thinBlock,unsigned char hops,const CNode* skip)
- @@ -494,7 +495,7 @@
- std::vector<CNode*>::iterator elem = std::find(xpeditedBlkUp.begin(), xpeditedBlkUp.end(),node);
- if ((flags & EXPEDITED_BLOCKS)&&(flags & EXPEDITED_STOP))
- {
- - if (elem == xpeditedBlkUp.end()) xpeditedBlkUp.erase(elem);
- + if (elem != xpeditedBlkUp.end()) xpeditedBlkUp.erase(elem);
- }
- else if (flags & EXPEDITED_BLOCKS)
- {
- @@ -1212,23 +1213,27 @@
- {
- BOOST_FOREACH(string& strAddr, mapMultiArgs["-expeditedblock"])
- {
- - // Add the peer's listening port if it is empty
- - int pos1 = strAddr.rfind(":");
- - int pos2 = strAddr.rfind("]:");
- - if (pos1 <= 0 && pos2 <= 0)
- - strAddr += ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- -
- string strListeningPeerIP;
- string strPeerIP = pfrom->addr.ToString();
- - pos1 = strPeerIP.rfind(":");
- - pos2 = strPeerIP.rfind("]:");
- - // Handle both ipv4 and ipv6 cases
- - if (pos1 <= 0 && pos2 <= 0)
- - strListeningPeerIP = strPeerIP + ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- - else if (pos1 > 0)
- - strListeningPeerIP = strPeerIP.substr(0, pos1) + ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- - else
- - strListeningPeerIP = strPeerIP.substr(0, pos2) + ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- + // Add the peer's listening port if it was provided (only misbehaving clients do not provide it)
- + if (pfrom->addrFromPort != 0)
- + {
- + int pos1 = strAddr.rfind(":");
- + int pos2 = strAddr.rfind("]:");
- + if (pos1 <= 0 && pos2 <= 0)
- + strAddr += ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- +
- + pos1 = strPeerIP.rfind(":");
- + pos2 = strPeerIP.rfind("]:");
- + // Handle both ipv4 and ipv6 cases
- + if (pos1 <= 0 && pos2 <= 0)
- + strListeningPeerIP = strPeerIP + ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- + else if (pos1 > 0)
- + strListeningPeerIP = strPeerIP.substr(0, pos1) + ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- + else
- + strListeningPeerIP = strPeerIP.substr(0, pos2) + ':' + boost::lexical_cast<std::string>(pfrom->addrFromPort);
- + }
- + else strListeningPeerIP = strPeerIP;
- if(strAddr == strListeningPeerIP)
- {
- diff -Nru bitcoinunlimited-1.0.1.1/src/unlimited.h bitcoinunlimited-1.0.1.2/src/unlimited.h
- --- bitcoinunlimited-1.0.1.1/src/unlimited.h 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/unlimited.h 2017-03-21 23:57:43.000000000 +0000
- @@ -72,7 +72,7 @@
- CNode* FindLikelyNode(const std::string& addrName);
- // process incoming unsolicited block
- -void HandleExpeditedBlock(CDataStream& vRecv,CNode* pfrom);
- +bool HandleExpeditedBlock(CDataStream& vRecv,CNode* pfrom);
- // Convert the BUComments to the string client's "subversion" string
- extern void settingsToUserAgentString();
- diff -Nru bitcoinunlimited-1.0.1.1/src/util.h bitcoinunlimited-1.0.1.2/src/util.h
- --- bitcoinunlimited-1.0.1.1/src/util.h 2017-03-14 22:18:47.000000000 +0000
- +++ bitcoinunlimited-1.0.1.2/src/util.h 2017-03-21 23:57:43.000000000 +0000
- @@ -29,6 +29,15 @@
- #include <boost/signals2/signal.hpp>
- #include <boost/thread/exceptions.hpp>
- +#ifdef DEBUG_ASSERTION
- +/// If DEBUG_ASSERTION is enabled this asserts when the predicate is false.
- +// If DEBUG_ASSERTION is disabled and the predicate is false, it executes the execInRelease statements.
- +// Typically, the programmer will error out -- return false, raise an exception, etc in the execInRelease code.
- +#define DbgAssert(pred, execInRelease) do { assert(pred); } while(0)
- +#else
- +#define DbgAssert(pred, execInRelease) do { if (!(pred)) { execInRelease; }} while(0)
- +#endif
- +
- static const bool DEFAULT_LOGTIMEMICROS = false;
- static const bool DEFAULT_LOGIPS = true;
- static const bool DEFAULT_LOGTIMESTAMPS = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement