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()); }
bool db_tx::read_transaction_index( const sha256 & hash, transaction_index & index ) { index.set_null(); std::string key_tx = "tx"; data_buffer buffer; buffer.write_var_int(key_tx.size()); buffer.write_bytes(key_tx.data(), key_tx.size()); buffer.write_sha256(hash); return read(buffer, index); }
bool transaction::read_from_disk( db_tx & tx_db, const point_out & previous_out, transaction_index & tx_index ) { set_null(); if ( tx_db.read_transaction_index( previous_out.get_hash(), tx_index) == false ) { log_debug( "Transaction failed to read from disk, read transaction index " "failed, previous out = " << previous_out.get_hash().to_string().substr(0, 20) << "." ); return false; } if (read_from_disk(tx_index.get_transaction_position()) == false) { log_debug( "Transaction failed to read from disk, read from disk failed." ); return false; } if (previous_out.n() >= m_transactions_out.size()) { log_debug( "Transaction failed to read from disk, n is greater than outputs." ); set_null(); return false; } return true; }