diff options
author | Matt Corallo <git@bluematt.me> | 2016-06-08 15:43:50 -0700 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2016-06-19 23:06:55 -0700 |
commit | 56ba5167272bc5afa8629ad93f16ed5135490bf5 (patch) | |
tree | 3ca486c300465d1736c6e969099181d25096be85 /src | |
parent | 2f34a2e476ae9d0585c67e275d238e44119c56cf (diff) |
Add reconstruction debug logging
Diffstat (limited to 'src')
-rw-r--r-- | src/blockencodings.cpp | 16 | ||||
-rw-r--r-- | src/blockencodings.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index c6b79f4201..204de45c29 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -11,6 +11,7 @@ #include "streams.h" #include "txmempool.h" #include "main.h" +#include "util.h" #include <unordered_map> @@ -72,6 +73,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c } txn_available[lastprefilledindex] = std::make_shared<CTransaction>(cmpctblock.prefilledtxn[i].tx); } + prefilled_count = cmpctblock.prefilledtxn.size(); // Calculate map of txids -> positions and check mempool to see what we have (or dont) // Because well-formed cmpctblock messages will have a (relatively) uniform distribution @@ -103,11 +105,15 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c if (!have_txn[idit->second]) { txn_available[idit->second] = it->GetSharedTx(); have_txn[idit->second] = true; + mempool_count++; } else { // If we find two mempool txn that match the short id, just request it. // This should be rare enough that the extra bandwidth doesn't matter, // but eating a round-trip due to FillBlock failure would be annoying - txn_available[idit->second].reset(); + if (txn_available[idit->second]) { + txn_available[idit->second].reset(); + mempool_count--; + } } } // Though ideally we'd continue scanning for the two-txn-match-shortid case, @@ -117,6 +123,8 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c break; } + LogPrint("cmpctblock", "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), cmpctblock.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION)); + return READ_STATUS_OK; } @@ -154,5 +162,11 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector< return READ_STATUS_INVALID; } + LogPrint("cmpctblock", "Successfully reconstructed block %s with %lu txn prefilled, %lu txn from mempool and %lu txn requested\n", header.GetHash().ToString(), prefilled_count, mempool_count, vtx_missing.size()); + if (vtx_missing.size() < 5) { + for(const CTransaction& tx : vtx_missing) + LogPrint("cmpctblock", "Reconstructed block %s required tx %s\n", header.GetHash().ToString(), tx.GetHash().ToString()); + } + return READ_STATUS_OK; } diff --git a/src/blockencodings.h b/src/blockencodings.h index adc60c85d0..b980e9e286 100644 --- a/src/blockencodings.h +++ b/src/blockencodings.h @@ -192,6 +192,7 @@ public: class PartiallyDownloadedBlock { protected: std::vector<std::shared_ptr<const CTransaction> > txn_available; + size_t prefilled_count = 0, mempool_count = 0; CTxMemPool* pool; public: CBlockHeader header; |