diff options
| author | Pieter Wuille <[email protected]> | 2013-01-11 01:47:57 +0100 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2013-01-18 14:39:11 +0100 |
| commit | 2d1fa42e85c9164688aa69b3f54f015fbefc06aa (patch) | |
| tree | d24823340b02d7e00af350b4592325414d5940f4 /src/main.h | |
| parent | Merge pull request #2149 from sipa/fixtxoutrpc (diff) | |
| download | discoin-2d1fa42e85c9164688aa69b3f54f015fbefc06aa.tar.xz discoin-2d1fa42e85c9164688aa69b3f54f015fbefc06aa.zip | |
Add optional transaction index to databases
By specifying -txindex when initializing the database, a txid-to-diskpos
index is maintained in the blktree database. This database is used to
help answering getrawtransaction() RPC queries, when enabled.
Changing the -txindex value requires a -reindex; the client will abort
at startup if the database and the specified -txindex mismatch.
Diffstat (limited to 'src/main.h')
| -rw-r--r-- | src/main.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main.h b/src/main.h index 2d3a9f5bd..edfea7b51 100644 --- a/src/main.h +++ b/src/main.h @@ -93,6 +93,7 @@ extern bool fImporting; extern bool fReindex; extern bool fBenchmark; extern int nScriptCheckThreads; +extern bool fTxIndex; extern unsigned int nCoinCacheSize; // Settings @@ -196,9 +197,8 @@ static inline std::string BlockHashStr(const uint256& hash) bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut); -class CDiskBlockPos +struct CDiskBlockPos { -public: int nFile; unsigned int nPos; @@ -228,7 +228,27 @@ public: bool IsNull() const { return (nFile == -1); } }; +struct CDiskTxPos : public CDiskBlockPos +{ + unsigned int nTxOffset; // after header + + IMPLEMENT_SERIALIZE( + READWRITE(*(CDiskBlockPos*)this); + READWRITE(VARINT(nTxOffset)); + ) + + CDiskTxPos(const CDiskBlockPos &blockIn, unsigned int nTxOffsetIn) : CDiskBlockPos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) { + } + + CDiskTxPos() { + SetNull(); + } + void SetNull() { + CDiskBlockPos::SetNull(); + nTxOffset = 0; + } +}; /** An inpoint - a combination of a transaction and an index n into its vin */ |