Add and extend log statements

This commit is contained in:
warptangent 2015-02-11 15:55:53 -08:00
parent 59305d3137
commit 2531aa31f8
No known key found for this signature in database
GPG Key ID: 0E490BEBFBE4E92D
1 changed files with 10 additions and 6 deletions

View File

@ -167,8 +167,11 @@ void BlockchainLMDB::add_block( const block& blk
MDB_val_copy<crypto::hash> parent_key(blk.prev_id); MDB_val_copy<crypto::hash> parent_key(blk.prev_id);
MDB_val parent_h; MDB_val parent_h;
if (mdb_get(*m_write_txn, m_block_heights, &parent_key, &parent_h)) if (mdb_get(*m_write_txn, m_block_heights, &parent_key, &parent_h))
{
LOG_PRINT_L3("m_height: " << m_height);
LOG_PRINT_L3("parent_key: " << blk.prev_id);
throw0(DB_ERROR("Failed to get top block hash to check for new block's parent")); throw0(DB_ERROR("Failed to get top block hash to check for new block's parent"));
}
uint64_t parent_height = *(const uint64_t *)parent_h.mv_data; uint64_t parent_height = *(const uint64_t *)parent_h.mv_data;
if (parent_height != m_height - 1) if (parent_height != m_height - 1)
throw0(BLOCK_PARENT_DNE("Top block is not new block's parent")); throw0(BLOCK_PARENT_DNE("Top block is not new block's parent"));
@ -177,8 +180,9 @@ void BlockchainLMDB::add_block( const block& blk
MDB_val_copy<uint64_t> key(m_height); MDB_val_copy<uint64_t> key(m_height);
MDB_val_copy<blobdata> blob(block_to_blob(blk)); MDB_val_copy<blobdata> blob(block_to_blob(blk));
if (mdb_put(*m_write_txn, m_blocks, &key, &blob, 0)) auto res = mdb_put(*m_write_txn, m_blocks, &key, &blob, 0);
throw0(DB_ERROR("Failed to add block blob to db transaction")); if (res)
throw0(DB_ERROR(std::string("Failed to add block blob to db transaction: ").append(mdb_strerror(res)).c_str()));
MDB_val_copy<size_t> sz(block_size); MDB_val_copy<size_t> sz(block_size);
if (mdb_put(*m_write_txn, m_block_sizes, &key, &sz, 0)) if (mdb_put(*m_write_txn, m_block_sizes, &key, &sz, 0))
@ -505,8 +509,8 @@ void BlockchainLMDB::add_spent_key(const crypto::key_image& k_image)
char anything = '\0'; char anything = '\0';
unused.mv_size = sizeof(char); unused.mv_size = sizeof(char);
unused.mv_data = &anything; unused.mv_data = &anything;
if (mdb_put(*m_write_txn, m_spent_keys, &val_key, &unused, 0)) if (auto result = mdb_put(*m_write_txn, m_spent_keys, &val_key, &unused, 0))
throw1(DB_ERROR("Error adding spent key image to db transaction")); throw1(DB_ERROR(std::string("Error adding spent key image to db transaction: ").append(mdb_strerror(result)).c_str()));
} }
void BlockchainLMDB::remove_spent_key(const crypto::key_image& k_image) void BlockchainLMDB::remove_spent_key(const crypto::key_image& k_image)
@ -910,7 +914,7 @@ size_t BlockchainLMDB::get_block_size(const uint64_t& height) const
difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& height) const difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& height) const
{ {
LOG_PRINT_L3("BlockchainLMDB::" << __func__); LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " height: " << height);
check_open(); check_open();
txn_safe txn; txn_safe txn;