aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2018-03-30 00:39:08 -0700
committerJim Posen <jimpo@coinbase.com>2018-04-25 11:25:15 -0700
commita03f804f2aa0261ed3a47103dfe989ebd9302480 (patch)
tree0bb7e5c43cc73c6bf0a439e2f7c55632a029a547 /src/validation.cpp
parente0a3b80033be388b7b8ecce8bd4273867e4bb699 (diff)
downloadbitcoin-a03f804f2aa0261ed3a47103dfe989ebd9302480.tar.xz
[index] Move disk IO logic from GetTransaction to TxIndex::FindTx.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 5ea81bfc98..14257d78f9 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1029,27 +1029,7 @@ bool GetTransaction(const uint256& hash, CTransactionRef& txOut, const Consensus
}
if (g_txindex) {
- CDiskTxPos postx;
- if (g_txindex->FindTx(hash, postx)) {
- CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION);
- if (file.IsNull())
- return error("%s: OpenBlockFile failed", __func__);
- CBlockHeader header;
- try {
- file >> header;
- fseek(file.Get(), postx.nTxOffset, SEEK_CUR);
- file >> txOut;
- } catch (const std::exception& e) {
- return error("%s: Deserialize or I/O error - %s", __func__, e.what());
- }
- hashBlock = header.GetHash();
- if (txOut->GetHash() != hash)
- return error("%s: txid mismatch", __func__);
- return true;
- }
-
- // transaction not found in index, nothing more can be done
- return false;
+ return g_txindex->FindTx(hash, hashBlock, txOut);
}
if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it