Changeset View
Changeset View
Standalone View
Standalone View
src/index/txindex.h
// Copyright (c) 2017-2018 The Bitcoin Core developers | // Copyright (c) 2017-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_INDEX_TXINDEX_H | #ifndef BITCOIN_INDEX_TXINDEX_H | ||||
#define BITCOIN_INDEX_TXINDEX_H | #define BITCOIN_INDEX_TXINDEX_H | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/transaction.h> | |||||
#include <threadinterrupt.h> | #include <threadinterrupt.h> | ||||
#include <txdb.h> | #include <txdb.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
class CBlockIndex; | class CBlockIndex; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public: | ||||
/// Blocks the current thread until the transaction index is caught up to | /// Blocks the current thread until the transaction index is caught up to | ||||
/// the current state of the block chain. This only blocks if the index has | /// the current state of the block chain. This only blocks if the index has | ||||
/// gotten in sync once and only needs to process blocks in the | /// gotten in sync once and only needs to process blocks in the | ||||
/// ValidationInterface queue. If the index is catching up from far behind, | /// ValidationInterface queue. If the index is catching up from far behind, | ||||
/// this method does not block and immediately returns false. | /// this method does not block and immediately returns false. | ||||
bool BlockUntilSyncedToCurrentChain(); | bool BlockUntilSyncedToCurrentChain(); | ||||
/// Look up the on-disk location of a transaction by hash. | /// Look up a transaction by hash. | ||||
bool FindTx(const uint256 &txid, CDiskTxPos &pos) const; | /// | ||||
/// @param[in] tx_hash The hash of the transaction to be returned. | |||||
/// @param[out] block_hash The hash of the block the transaction is found | |||||
/// in. | |||||
/// @param[out] tx The transaction itself. | |||||
/// @return true if transaction is found, false otherwise | |||||
bool FindTx(const uint256 &tx_hash, uint256 &block_hash, | |||||
CTransactionRef &tx) const; | |||||
void Interrupt(); | void Interrupt(); | ||||
/// Start initializes the sync state and registers the instance as a | /// Start initializes the sync state and registers the instance as a | ||||
/// ValidationInterface so that it stays in sync with blockchain updates. | /// ValidationInterface so that it stays in sync with blockchain updates. | ||||
void Start(); | void Start(); | ||||
/// Stops the instance from staying in sync with blockchain updates. | /// Stops the instance from staying in sync with blockchain updates. | ||||
void Stop(); | void Stop(); | ||||
}; | }; | ||||
/// The global transaction index, used in GetTransaction. May be null. | |||||
extern std::unique_ptr<TxIndex> g_txindex; | |||||
#endif // BITCOIN_INDEX_TXINDEX_H | #endif // BITCOIN_INDEX_TXINDEX_H |