aboutsummaryrefslogtreecommitdiff
path: root/src/blockencodings.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-06-08 15:43:50 -0700
committerMatt Corallo <git@bluematt.me>2016-06-19 23:06:55 -0700
commit56ba5167272bc5afa8629ad93f16ed5135490bf5 (patch)
tree3ca486c300465d1736c6e969099181d25096be85 /src/blockencodings.cpp
parent2f34a2e476ae9d0585c67e275d238e44119c56cf (diff)
downloadbitcoin-56ba5167272bc5afa8629ad93f16ed5135490bf5.tar.xz
Add reconstruction debug logging
Diffstat (limited to 'src/blockencodings.cpp')
-rw-r--r--src/blockencodings.cpp16
1 files changed, 15 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;
}