|
16 | 16 | #include <consensus/validation.h>
|
17 | 17 | #include <cuckoocache.h>
|
18 | 18 | #include <hash.h>
|
| 19 | +#include <index/txindex.h> |
19 | 20 | #include <init.h>
|
20 | 21 | #include <policy/fees.h>
|
21 | 22 | #include <policy/policy.h>
|
@@ -217,7 +218,6 @@ uint256 g_best_block;
|
217 | 218 | int nScriptCheckThreads = 0;
|
218 | 219 | std::atomic_bool fImporting(false);
|
219 | 220 | std::atomic_bool fReindex(false);
|
220 |
| -bool fTxIndex = false; |
221 | 221 | bool fHavePruned = false;
|
222 | 222 | bool fPruneMode = false;
|
223 | 223 | bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
|
@@ -1028,9 +1028,9 @@ bool GetTransaction(const uint256& hash, CTransactionRef& txOut, const Consensus
|
1028 | 1028 | return true;
|
1029 | 1029 | }
|
1030 | 1030 |
|
1031 |
| - if (fTxIndex) { |
| 1031 | + if (g_txindex) { |
1032 | 1032 | CDiskTxPos postx;
|
1033 |
| - if (pblocktree->ReadTxIndex(hash, postx)) { |
| 1033 | + if (g_txindex->FindTx(hash, postx)) { |
1034 | 1034 | CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION);
|
1035 | 1035 | if (file.IsNull())
|
1036 | 1036 | return error("%s: OpenBlockFile failed", __func__);
|
@@ -1668,26 +1668,6 @@ static bool WriteUndoDataForBlock(const CBlockUndo& blockundo, CValidationState&
|
1668 | 1668 | return true;
|
1669 | 1669 | }
|
1670 | 1670 |
|
1671 |
| -static bool WriteTxIndexDataForBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex) |
1672 |
| -{ |
1673 |
| - if (!fTxIndex) return true; |
1674 |
| - |
1675 |
| - CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); |
1676 |
| - std::vector<std::pair<uint256, CDiskTxPos> > vPos; |
1677 |
| - vPos.reserve(block.vtx.size()); |
1678 |
| - for (const CTransactionRef& tx : block.vtx) |
1679 |
| - { |
1680 |
| - vPos.push_back(std::make_pair(tx->GetHash(), pos)); |
1681 |
| - pos.nTxOffset += ::GetSerializeSize(*tx, SER_DISK, CLIENT_VERSION); |
1682 |
| - } |
1683 |
| - |
1684 |
| - if (!pblocktree->WriteTxIndex(vPos)) { |
1685 |
| - return AbortNode(state, "Failed to write transaction index"); |
1686 |
| - } |
1687 |
| - |
1688 |
| - return true; |
1689 |
| -} |
1690 |
| - |
1691 | 1671 | static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
|
1692 | 1672 |
|
1693 | 1673 | void ThreadScriptCheck() {
|
@@ -2079,9 +2059,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
2079 | 2059 | setDirtyBlockIndex.insert(pindex);
|
2080 | 2060 | }
|
2081 | 2061 |
|
2082 |
| - if (!WriteTxIndexDataForBlock(block, state, pindex)) |
2083 |
| - return false; |
2084 |
| - |
2085 | 2062 | assert(pindex->phashBlock);
|
2086 | 2063 | // add this block to the view's block chain
|
2087 | 2064 | view.SetBestBlock(pindex->GetBlockHash());
|
@@ -3903,10 +3880,6 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
3903 | 3880 | pblocktree->ReadReindexing(fReindexing);
|
3904 | 3881 | if(fReindexing) fReindex = true;
|
3905 | 3882 |
|
3906 |
| - // Check whether we have a transaction index |
3907 |
| - pblocktree->ReadFlag("txindex", fTxIndex); |
3908 |
| - LogPrintf("%s: transaction index %s\n", __func__, fTxIndex ? "enabled" : "disabled"); |
3909 |
| - |
3910 | 3883 | return true;
|
3911 | 3884 | }
|
3912 | 3885 |
|
@@ -4300,9 +4273,6 @@ bool LoadBlockIndex(const CChainParams& chainparams)
|
4300 | 4273 | // needs_init.
|
4301 | 4274 |
|
4302 | 4275 | LogPrintf("Initializing databases...\n");
|
4303 |
| - // Use the provided setting for -txindex in the new database |
4304 |
| - fTxIndex = gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX); |
4305 |
| - pblocktree->WriteFlag("txindex", fTxIndex); |
4306 | 4276 | }
|
4307 | 4277 | return true;
|
4308 | 4278 | }
|
|
0 commit comments