From 2fcb6de1a83baa87a006a0438c153ee12c92afaf Mon Sep 17 00:00:00 2001 From: Peter Shugalev Date: Fri, 25 Nov 2022 00:33:05 +0100 Subject: [PATCH] Code for dumping all the ISLocked transactions --- src/llmq/quorums_instantsend.cpp | 33 ++++++++++++++++++++++++++++++++ src/llmq/quorums_instantsend.h | 1 + 2 files changed, 34 insertions(+) diff --git a/src/llmq/quorums_instantsend.cpp b/src/llmq/quorums_instantsend.cpp index 9db3cade75..6e5c6c5bf5 100644 --- a/src/llmq/quorums_instantsend.cpp +++ b/src/llmq/quorums_instantsend.cpp @@ -1167,6 +1167,39 @@ void CInstantSendManager::NotifyChainLock(const CBlockIndex* pindexChainLock) void CInstantSendManager::UpdatedBlockTip(const CBlockIndex* pindexNew) { + /*uint256 txhash; + txhash.SetHex("af274b213d1210694d6f0933ddab0c15e00f66185ed6cd93b496f578a5864905"); + AskNodesForLockedTx(txhash);*/ + + static bool firstIteration = true; + + if (firstIteration) { + FILE *f = fopen("/tmp/islock.dump", "wt"); + + auto it = std::unique_ptr(db.db.NewIterator()); + auto firstKey = std::make_tuple(std::string("is_i"), uint256()); + it->Seek(firstKey); + while (it->Valid()) { + decltype(firstKey) curKey; + if (!it->GetKey(curKey) || std::get<0>(curKey) != "is_i") + break; + + CInstantSendLock islock; + + if (db.db.Read(curKey, islock)) { + bool fArchived = db.HasArchivedInstantSendLock(std::get<1>(curKey)); + fprintf(f, "[%c] %s:\n", fArchived ? 'A' : ' ', islock.txid.ToString().c_str()); + for (auto &in: islock.inputs) { + fprintf(f, " %s:%d\n", in.hash.ToString().c_str(), (int)in.n); + } + } + + it->Next(); + } + fclose(f); + firstIteration = false; + } + bool fDIP0008Active = pindexNew->pprev && pindexNew->pprev->nHeight >= Params().GetConsensus().DIP0008Height; if (fDIP0008Active && IsChainlocksEnabled()) { diff --git a/src/llmq/quorums_instantsend.h b/src/llmq/quorums_instantsend.h index fd73d06689..c62593b84a 100644 --- a/src/llmq/quorums_instantsend.h +++ b/src/llmq/quorums_instantsend.h @@ -42,6 +42,7 @@ typedef std::shared_ptr CInstantSendLockPtr; class CInstantSendDb { +friend class CInstantSendManager; private: CDBWrapper& db;