bool utility::get_transaction( const sha256 & hash_tx, transaction & tx, sha256 & hash_block_out ) { if (transaction_pool::instance().exists(hash_tx)) { tx = transaction_pool::instance().lookup(hash_tx); return true; } db_tx tx_db("r"); transaction_index index; if (tx.read_from_disk(tx_db, point_out(hash_tx, 0), index)) { block blk; if ( blk.read_from_disk(index.get_transaction_position().file_index(), index.get_transaction_position().block_position(), false) ) { hash_block_out = blk.get_hash(); } return true; } return false; }
bool db_tx::read_disk_transaction( const sha256 & hash, transaction & tx, transaction_index & index ) { assert(globals::instance().is_client() == false); tx.set_null(); if (read_transaction_index(hash, index) == false) { return false; } return tx.read_from_disk(index.get_transaction_position()); }