Changeset View
Changeset View
Standalone View
Standalone View
src/index/txindex.cpp
Show First 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | bool TxIndex::FindTx(const TxId &txid, uint256 &block_hash, | ||||
CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); | CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); | ||||
if (file.IsNull()) { | if (file.IsNull()) { | ||||
return error("%s: OpenBlockFile failed", __func__); | return error("%s: OpenBlockFile failed", __func__); | ||||
} | } | ||||
CBlockHeader header; | CBlockHeader header; | ||||
try { | try { | ||||
file >> header; | file >> header; | ||||
fseek(file.Get(), postx.nTxOffset, SEEK_CUR); | if (fseek(file.Get(), postx.nTxOffset, SEEK_CUR)) { | ||||
return error("%s: fseek(...) failed", __func__); | |||||
} | |||||
file >> tx; | file >> tx; | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
return error("%s: Deserialize or I/O error - %s", __func__, e.what()); | return error("%s: Deserialize or I/O error - %s", __func__, e.what()); | ||||
} | } | ||||
if (tx->GetId() != txid) { | if (tx->GetId() != txid) { | ||||
return error("%s: txid mismatch", __func__); | return error("%s: txid mismatch", __func__); | ||||
} | } | ||||
block_hash = header.GetHash(); | block_hash = header.GetHash(); | ||||
return true; | return true; | ||||
} | } |