Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 787 Lines • ▼ Show 20 Lines | |||||
bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | ||||
TxValidationState &state, const CTransactionRef &tx, | TxValidationState &state, const CTransactionRef &tx, | ||||
bool bypass_limits, const Amount nAbsurdFee, | bool bypass_limits, const Amount nAbsurdFee, | ||||
bool test_accept) { | bool test_accept) { | ||||
return AcceptToMemoryPoolWithTime(config, pool, state, tx, GetTime(), | return AcceptToMemoryPoolWithTime(config, pool, state, tx, GetTime(), | ||||
bypass_limits, nAbsurdFee, test_accept); | bypass_limits, nAbsurdFee, test_accept); | ||||
} | } | ||||
/** | CTransactionRef GetTransaction(const CBlockIndex *const block_index, | ||||
* Return transaction in txOut, and if it was found inside a block, its hash is | const CTxMemPool *const mempool, | ||||
* placed in hashBlock. If blockIndex is provided, the transaction is fetched | const TxId &txid, | ||||
* from the corresponding block. | const Consensus::Params &consensusParams, | ||||
*/ | BlockHash &hashBlock) { | ||||
bool GetTransaction(const TxId &txid, CTransactionRef &txOut, | |||||
const Consensus::Params ¶ms, BlockHash &hashBlock, | |||||
const CBlockIndex *const block_index) { | |||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (block_index == nullptr) { | if (block_index) { | ||||
CTransactionRef ptx = g_mempool.get(txid); | |||||
if (ptx) { | |||||
txOut = ptx; | |||||
return true; | |||||
} | |||||
if (g_txindex) { | |||||
return g_txindex->FindTx(txid, hashBlock, txOut); | |||||
} | |||||
} else { | |||||
CBlock block; | CBlock block; | ||||
if (ReadBlockFromDisk(block, block_index, params)) { | if (ReadBlockFromDisk(block, block_index, consensusParams)) { | ||||
for (const auto &tx : block.vtx) { | for (const auto &tx : block.vtx) { | ||||
if (tx->GetId() == txid) { | if (tx->GetId() == txid) { | ||||
txOut = tx; | |||||
hashBlock = block_index->GetBlockHash(); | hashBlock = block_index->GetBlockHash(); | ||||
return true; | return tx; | ||||
} | |||||
} | } | ||||
} | } | ||||
return nullptr; | |||||
} | |||||
if (mempool) { | |||||
CTransactionRef ptx = mempool->get(txid); | |||||
if (ptx) { | |||||
return ptx; | |||||
} | } | ||||
} | } | ||||
if (g_txindex) { | |||||
return false; | CTransactionRef tx; | ||||
if (g_txindex->FindTx(txid, hashBlock, tx)) { | |||||
return tx; | |||||
} | |||||
} | |||||
return nullptr; | |||||
} | } | ||||
////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////// | ||||
// | // | ||||
// CBlock and CBlockIndex | // CBlock and CBlockIndex | ||||
// | // | ||||
static bool WriteBlockToDisk(const CBlock &block, FlatFilePos &pos, | static bool WriteBlockToDisk(const CBlock &block, FlatFilePos &pos, | ||||
▲ Show 20 Lines • Show All 5,327 Lines • Show Last 20 Lines |