Skip to content

Commit

Permalink
Move messages to debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
LenyKholodov committed Mar 28, 2019
1 parent b2da16e commit 6117820
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
33 changes: 18 additions & 15 deletions src/cryptonote_core/stake_transaction_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "stake_transaction_processor.h"
#include "../graft_rta_config.h"

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "staketransaction.processor"

using namespace cryptonote;

namespace
Expand Down Expand Up @@ -53,7 +56,7 @@ uint64_t get_transaction_amount(const transaction& tx, const account_public_addr

if (!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation))
{
MCLOG(el::Level::Warning, "global", "failed to generate key derivation from supplied parameters");
MWARNING("failed to generate key derivation from supplied parameters");
return 0;
}

Expand Down Expand Up @@ -134,7 +137,7 @@ void StakeTransactionProcessor::init_storages_impl()
if (first_block_number)
first_block_number--;

MCLOG(el::Level::Info, "global", "Initialize stake processing storages. First block height is " << first_block_number);
MDEBUG("Initialize stake processing storages. First block height is " << first_block_number);

m_storage.reset(new StakeTransactionStorage(m_config_dir + "/" + STAKE_TRANSACTION_STORAGE_FILE_NAME, first_block_number));
m_blockchain_based_list.reset(new BlockchainBasedList(m_config_dir + "/" + BLOCKCHAIN_BASED_LIST_FILE_NAME, first_block_number));
Expand Down Expand Up @@ -165,7 +168,7 @@ void StakeTransactionProcessor::process_block_stake_transaction(uint64_t block_i
crypto::public_key W;
if (!epee::string_tools::hex_to_pod(stake_tx.supernode_public_id, W) || !check_key(W))
{
MCLOG(el::Level::Warning, "global", "Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash
MWARNING("Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash
<< " because of invalid supernode public identifier '" << stake_tx.supernode_public_id << "'");
continue;
}
Expand All @@ -177,7 +180,7 @@ void StakeTransactionProcessor::process_block_stake_transaction(uint64_t block_i

if (!crypto::check_signature(hash, W, stake_tx.supernode_signature))
{
MCLOG(el::Level::Warning, "global", "Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
MWARNING("Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
<< " because of invalid supernode signature (mismatch)");
continue;
}
Expand All @@ -186,14 +189,14 @@ void StakeTransactionProcessor::process_block_stake_transaction(uint64_t block_i

if (unlock_time < config::graft::STAKE_MIN_UNLOCK_TIME)
{
MCLOG(el::Level::Warning, "global", "Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
MWARNING("Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
<< " because unlock time " << unlock_time << " is less than minimum allowed " << config::graft::STAKE_MIN_UNLOCK_TIME);
continue;
}

if (unlock_time > config::graft::STAKE_MAX_UNLOCK_TIME)
{
MCLOG(el::Level::Warning, "global", "Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
MWARNING("Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
<< " because unlock time " << unlock_time << " is greater than maximum allowed " << config::graft::STAKE_MAX_UNLOCK_TIME);
continue;
}
Expand All @@ -202,7 +205,7 @@ void StakeTransactionProcessor::process_block_stake_transaction(uint64_t block_i

if (!amount)
{
MCLOG(el::Level::Warning, "global", "Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
MWARNING("Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
<< " because of error at parsing amount");
continue;
}
Expand All @@ -214,16 +217,16 @@ void StakeTransactionProcessor::process_block_stake_transaction(uint64_t block_i

m_storage->add_tx(stake_tx);

MCLOG(el::Level::Info, "global", "New stake transaction found at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id
MDEBUG("New stake transaction found at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id
<< "', amount=" << amount / double(COIN));
}
catch (std::exception& e)
{
MCLOG(el::Level::Warning, "global", "Ignore transaction at block #" << block_index << ", tx_hash=" << tx_hash << " because of error at parsing: " << e.what());
MWARNING("Ignore transaction at block #" << block_index << ", tx_hash=" << tx_hash << " because of error at parsing: " << e.what());
}
catch (...)
{
MCLOG(el::Level::Warning, "global", "Ignore transaction at block #" << block_index << ", tx_hash=" << tx_hash << " because of unknown error at parsing");
MWARNING("Ignore transaction at block #" << block_index << ", tx_hash=" << tx_hash << " because of unknown error at parsing");
}
}

Expand Down Expand Up @@ -305,7 +308,7 @@ void StakeTransactionProcessor::synchronize()
}
}

MCLOG(el::Level::Warning, "global", "Stake transactions processing: unroll block " << last_processed_block_index << " (height=" << height << ")");
MWARNING("Stake transactions processing: unroll block " << last_processed_block_index << " (height=" << height << ")");

m_storage->remove_last_processed_block();

Expand Down Expand Up @@ -335,7 +338,7 @@ void StakeTransactionProcessor::synchronize()
for (; last_block_index<last_block_index_for_sync; last_block_index++)
{
if (last_block_index % SYNC_DEBUG_LOG_STEP == 0 || last_block_index == height - 1)
MCLOG(el::Level::Info, "global", "RTA block sync " << last_block_index << "/" << (height - 1));
MDEBUG("RTA block sync " << last_block_index << "/" << (height - 1));

try
{
Expand Down Expand Up @@ -366,7 +369,7 @@ void StakeTransactionProcessor::synchronize()
invoke_update_blockchain_based_list_handler_impl(last_block_index - first_block_index);

if (first_block_index != last_block_index)
MCLOG(el::Level::Info, "global", "Stake transactions sync OK");
MDEBUG("Stake transactions sync OK");
}
}
catch (const std::exception &e)
Expand Down Expand Up @@ -394,7 +397,7 @@ void StakeTransactionProcessor::invoke_update_stakes_handler_impl(uint64_t block
}
catch (std::exception& e)
{
MCLOG(el::Level::Error, "global", "exception in StakeTransactionProcessor stake transactions update handler: " << e.what());
MCLOG(el::Level::Error, MONERO_DEFAULT_LOG_CATEGORY, "exception in StakeTransactionProcessor stake transactions update handler: " << e.what());
}
}

Expand Down Expand Up @@ -442,7 +445,7 @@ void StakeTransactionProcessor::invoke_update_blockchain_based_list_handler_impl
}
catch (std::exception& e)
{
MCLOG(el::Level::Error, "global", "exception in StakeTransactionProcessor blockchain based list update handler: " << e.what());
MCLOG(el::Level::Error, MONERO_DEFAULT_LOG_CATEGORY, "exception in StakeTransactionProcessor blockchain based list update handler: " << e.what());
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/cryptonote_core/stake_transaction_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "cryptonote_basic/account_boost_serialization.h"
#include "../graft_rta_config.h"

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "staketransaction.storage"

using namespace cryptonote;

namespace
Expand Down Expand Up @@ -145,7 +148,7 @@ void StakeTransactionStorage::update_supernode_stakes(uint64_t block_number)
if (block_number == m_supernode_stakes_update_block_number)
return;

MCLOG(el::Level::Info, "global", "Build stakes for block " << block_number);
MDEBUG("Build stakes for block " << block_number);

m_supernode_stakes.clear();
m_supernode_stake_indexes.clear();
Expand All @@ -170,7 +173,7 @@ void StakeTransactionStorage::update_supernode_stakes(uint64_t block_number)
obsolete_stake = true;
}

MCLOG(el::Level::Info, "global", "...use stake transaction " << tx.hash << " as " << (obsolete_stake ? "obsolete" : "normal") << " stake transaction ");
MDEBUG("...use stake transaction " << tx.hash << " as " << (obsolete_stake ? "obsolete" : "normal") << " stake transaction ");

//compute stake validity period

Expand Down Expand Up @@ -201,7 +204,7 @@ void StakeTransactionStorage::update_supernode_stakes(uint64_t block_number)
new_stake.block_height = min_tx_block_height;
new_stake.unlock_time = max_tx_block_height - min_tx_block_height;

MCLOG(el::Level::Info, "global", "...first stake transaction for supernode " << tx.supernode_public_id << ": amount=" << tx.amount << ", tier=" <<
MDEBUG("...first stake transaction for supernode " << tx.supernode_public_id << ": amount=" << tx.amount << ", tier=" <<
new_stake.tier << ", validity=[" << min_tx_block_height << ";" << max_tx_block_height << ")");
}

Expand All @@ -220,7 +223,7 @@ void StakeTransactionStorage::update_supernode_stakes(uint64_t block_number)
if (obsolete_stake)
continue; //no need to aggregate fields from obsolete stake

MCLOG(el::Level::Info, "global", "...accumulate stake transaction for supernode " << tx.supernode_public_id << ": amount=" << tx.amount <<
MDEBUG("...accumulate stake transaction for supernode " << tx.supernode_public_id << ": amount=" << tx.amount <<
", validity=[" << min_tx_block_height << ";" << max_tx_block_height << ")");

supernode_stake& stake = m_supernode_stakes[it->second];
Expand Down Expand Up @@ -259,7 +262,7 @@ void StakeTransactionStorage::update_supernode_stakes(uint64_t block_number)
stake.block_height = min_block_height;
stake.unlock_time = max_block_height - min_block_height;

MCLOG(el::Level::Info, "global", "...stake for supernode " << tx.supernode_public_id << ": amount=" << stake.amount << ", tier=" << stake.tier <<
MDEBUG("...stake for supernode " << tx.supernode_public_id << ": amount=" << stake.amount << ", tier=" << stake.tier <<
", validity=[" << min_block_height << ";" << max_block_height << ")");
}
}
Expand Down

0 comments on commit 6117820

Please sign in to comment.