From 70352e11c0194fe4e71efea06220544749f4cd64 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 27 Aug 2014 18:04:09 +0200 Subject: [PATCH] Revert "Add a getutxos command to the p2p protocol. It allows querying of the UTXO set" This reverts commit da2ec100f3681176f60dec6dc675fc64147ade3a. --- src/main.cpp | 86 -------------------------------------------------- src/net.cpp | 2 +- src/protocol.h | 1 - src/version.h | 2 +- 4 files changed, 2 insertions(+), 89 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6567c77e9..7dd1c2c06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,6 @@ #include -#include #include #include #include @@ -3519,75 +3518,6 @@ void static ProcessGetData(CNode* pfrom) } } -struct CCoin { - uint32_t nTxVer; // Don't call this nVersion, that name has a special meaning inside IMPLEMENT_SERIALIZE - uint32_t nHeight; - CTxOut out; - - IMPLEMENT_SERIALIZE( - READWRITE(nTxVer); - READWRITE(nHeight); - READWRITE(out); - ) -}; - -bool ProcessGetUTXOs(const vector &vOutPoints, bool fCheckMemPool, vector *result, vector *resultCoins) -{ - // Defined by BIP 64. - // - // Allows a peer to retrieve the CTxOut structures corresponding to the given COutPoints. - // Note that this data is not authenticated by anything: this code could just invent any - // old rubbish and hand it back, with the peer being unable to tell unless they are checking - // the outpoints against some out of band data. - // - // Also the answer could change the moment after we give it. However some apps can tolerate - // this, because they're only using the result as a hint or are willing to trust the results - // based on something else. For example we may be a "trusted node" for the peer, or it may - // be checking the results given by several nodes for consistency, it may - // run the UTXOs returned against scriptSigs of transactions obtained elsewhere (after checking - // for a standard script form), and because the height in which the UTXO was defined is provided - // a client that has a map of heights to block headers (as SPV clients do, for recent blocks) - // can request the creating block via hash. - // - // IMPORTANT: Clients expect ordering to be preserved! - if (vOutPoints.size() > MAX_INV_SZ) - return error("message getutxos size() = %u", vOutPoints.size()); - - LogPrint("net", "getutxos for %d queries %s mempool\n", vOutPoints.size(), fCheckMemPool ? "with" : "without"); - - boost::dynamic_bitset hits(vOutPoints.size()); - { - LOCK2(cs_main, mempool.cs); - CCoinsViewMemPool cvMemPool(*pcoinsTip, mempool); - CCoinsViewCache view(fCheckMemPool ? cvMemPool : *pcoinsTip); - for (size_t i = 0; i < vOutPoints.size(); i++) - { - CCoins coins; - uint256 hash = vOutPoints[i].hash; - if (view.GetCoins(hash, coins)) - { - mempool.pruneSpent(hash, coins); - if (coins.IsAvailable(vOutPoints[i].n)) - { - hits[i] = true; - // Safe to index into vout here because IsAvailable checked if it's off the end of the array, or if - // n is valid but points to an already spent output (IsNull). - CCoin coin; - coin.nTxVer = coins.nVersion; - coin.nHeight = coins.nHeight; - coin.out = coins.vout.at(vOutPoints[i].n); - assert(!coin.out.IsNull()); - resultCoins->push_back(coin); - } - } - } - } - - boost::to_block_range(hits, std::back_inserter(*result)); - return true; -} - - bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived) { RandAddSeedPerfmon(); @@ -3936,22 +3866,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (strCommand == "getutxos") - { - bool fCheckMemPool; - vector vOutPoints; - vRecv >> fCheckMemPool; - vRecv >> vOutPoints; - - vector bitmap; - vector outs; - if (ProcessGetUTXOs(vOutPoints, fCheckMemPool, &bitmap, &outs)) - pfrom->PushMessage("utxos", chainActive.Height(), chainActive.Tip()->GetBlockHash(), bitmap, outs); - else - Misbehaving(pfrom->GetId(), 20); - } - - else if (strCommand == "tx") { vector vWorkQueue; diff --git a/src/net.cpp b/src/net.cpp index e2adba851..396670620 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -67,7 +67,7 @@ namespace { // bool fDiscover = true; bool fListen = true; -uint64_t nLocalServices = NODE_NETWORK | NODE_GETUTXOS; +uint64_t nLocalServices = NODE_NETWORK; CCriticalSection cs_mapLocalHost; map mapLocalHost; static bool vfReachable[NET_MAX] = {}; diff --git a/src/protocol.h b/src/protocol.h index 94d313e9c..d7565584a 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -64,7 +64,6 @@ class CMessageHeader enum { NODE_NETWORK = (1 << 0), - NODE_GETUTXOS = (1 << 1), // Bits 24-31 are reserved for temporary experiments. Just pick a bit that // isn't getting used, or one not being used much, and notify the diff --git a/src/version.h b/src/version.h index 3a6c0f371..b87aa8258 100644 --- a/src/version.h +++ b/src/version.h @@ -27,7 +27,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70003; +static const int PROTOCOL_VERSION = 70002; // initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209;