diff options
Diffstat (limited to 'src/cryptonote_core/blockchain_db.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain_db.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/cryptonote_core/blockchain_db.cpp b/src/cryptonote_core/blockchain_db.cpp index 02912be10..c7109dd20 100644 --- a/src/cryptonote_core/blockchain_db.cpp +++ b/src/cryptonote_core/blockchain_db.cpp @@ -29,6 +29,8 @@ #include "cryptonote_core/blockchain_db.h" #include "cryptonote_format_utils.h" +using epee::string_tools::pod_to_hex; + namespace cryptonote { @@ -43,20 +45,31 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti { crypto::hash tx_hash = get_transaction_hash(tx); + LOG_PRINT_L0("Adding tx with hash " << pod_to_hex(tx_hash) << " to BlockchainDB instance"); + LOG_PRINT_L0("Included in block with hash " << pod_to_hex(blk_hash)); + LOG_PRINT_L0("Unlock time == " << tx.unlock_time); + add_transaction_data(blk_hash, tx); // iterate tx.vout using indices instead of C++11 foreach syntax because // we need the index - for (uint64_t i = 0; i < tx.vout.size(); ++i) + if (tx.vout.size() != 0) // it may be technically possible for a tx to have no outputs { - add_output(tx_hash, tx.vout[i], i); - } + for (uint64_t i = 0; i < tx.vout.size(); ++i) + { + add_output(tx_hash, tx.vout[i], i); + } - for (const txin_v& tx_input : tx.vin) - { - if (tx_input.type() == typeid(txin_to_key)) + for (const txin_v& tx_input : tx.vin) { - add_spent_key(boost::get<txin_to_key>(tx_input).k_image); + if (tx_input.type() == typeid(txin_to_key)) + { + add_spent_key(boost::get<txin_to_key>(tx_input).k_image); + } + else + { + LOG_PRINT_L0("Is miner tx"); + } } } } @@ -68,10 +81,12 @@ uint64_t BlockchainDB::add_block( const block& blk , const std::vector<transaction>& txs ) { + crypto::hash blk_hash = get_block_hash(blk); + LOG_PRINT_L0("Adding block with hash " << pod_to_hex(blk_hash) << " to BlockchainDB instance."); + // call out to subclass implementation to add the block & metadata add_block(blk, block_size, cumulative_difficulty, coins_generated); - crypto::hash blk_hash = get_block_hash(blk); // call out to add the transactions add_transaction(blk_hash, blk.miner_tx); |