Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daemon SonarCloud #269

Merged
merged 11 commits into from
Feb 21, 2022
14 changes: 7 additions & 7 deletions src/Common/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ std::string get_nix_version_display_string()
std::string getDefaultDataDirectory()
{
//namespace fs = boost::filesystem;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\CRYPTONOTE_NAME
// Windows >= Vista: C:\Users\Username\AppData\Roaming\CRYPTONOTE_NAME
// Mac: ~/Library/Application Support/CRYPTONOTE_NAME
// Unix: ~/.CRYPTONOTE_NAME
// Windows < Vista: C:\Documents and Settings\Username\Application Data\BLOCKCHAIN_DIR
// Windows >= Vista: C:\Users\Username\AppData\Roaming\BLOCKCHAIN_DIR
// Mac: ~/Library/Application Support/BLOCKCHAIN_DIR
// Unix: ~/.BLOCKCHAIN_DIR
std::string config_folder;
#ifdef _WIN32
// Windows
config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + cn::CRYPTONOTE_NAME;
config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + cn::BLOCKCHAIN_DIR;
#else
std::string pathRet;
char* pszHome = getenv("HOME");
Expand All @@ -307,10 +307,10 @@ std::string get_nix_version_display_string()
#ifdef MAC_OSX
// Mac
pathRet /= "Library/Application Support";
config_folder = (pathRet + "/" + cn::CRYPTONOTE_NAME);
config_folder = (pathRet + "/" + cn::BLOCKCHAIN_DIR);
#else
// Unix
config_folder = (pathRet + "/." + cn::CRYPTONOTE_NAME);
config_folder = (pathRet + "/." + cn::BLOCKCHAIN_DIR);
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace cn
const uint64_t MAX_BLOCK_REWARD_V1 = (UINT64_C(6) * parameters::COIN);
const uint64_t REWARD_INCREASE_INTERVAL = (UINT64_C(21900)); // aprox. 1 month (+ 0.25 CCX increment per month)

const char CRYPTONOTE_NAME[] = "conceal";
const char BLOCKCHAIN_DIR[] = "conceal";
const char GENESIS_COINBASE_TX_HEX[] = "010a01ff0001c096b102029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017d6775185749e95ac2d70cae3f29e0e46f430ab648abbe9fdc61d8e7437c60f8";
const uint32_t GENESIS_NONCE = 10000;
const uint64_t GENESIS_TIMESTAMP = 1527078920;
Expand Down
22 changes: 14 additions & 8 deletions src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ namespace cn

if (load_existing && !m_blocks.empty())
{
logger(INFO, BRIGHT_WHITE) << "Loading blockchain";
logger(INFO) << "Loading blockchain";
BlockCacheSerializer loader(*this, get_block_hash(m_blocks.back().bl), logger.getLogger());
loader.load(appendPath(config_folder, m_currency.blocksCacheFileName()));

Expand Down Expand Up @@ -1862,18 +1862,24 @@ namespace cn
logger(INFO, BRIGHT_WHITE) << "Blockchain printed with log level 1";
}

void Blockchain::print_blockchain_index()
void Blockchain::print_blockchain_index(bool print_all)
{
std::stringstream ss;
std::lock_guard<decltype(m_blockchain_lock)> lk(m_blockchain_lock);

std::vector<crypto::Hash> blockIds = m_blockIndex.getBlockIds(0, std::numeric_limits<uint32_t>::max());
logger(INFO, BRIGHT_WHITE) << "Current blockchain index:";

size_t height = 0;
for (auto i = blockIds.begin(); i != blockIds.end(); ++i, ++height)
if (print_all == false)
{
logger(INFO, BRIGHT_WHITE) << "id\t\t" << *i << " height" << height;
std::string id = common::podToHex(m_blockIndex.getBlockId(getCurrentBlockchainHeight()));
logger(INFO, BRIGHT_WHITE) << "id\t\t" << id << " height" << getCurrentBlockchainHeight();
}
else
{
std::vector<crypto::Hash> blockIds = m_blockIndex.getBlockIds(0, std::numeric_limits<uint32_t>::max());
logger(INFO, BRIGHT_WHITE) << "Current blockchain index:";
size_t height = 0;

for (auto i = blockIds.begin(); i != blockIds.end(); ++i, ++height)
logger(INFO, BRIGHT_WHITE) << "id\t\t" << *i << " height" << height;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/CryptoNoteCore/Blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace cn

//debug functions
void print_blockchain(uint64_t start_index, uint64_t end_index);
void print_blockchain_index();
void print_blockchain_index(bool print_all);
void print_blockchain_outs(const std::string &file);

struct TransactionIndex
Expand Down
4 changes: 2 additions & 2 deletions src/CryptoNoteCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ void core::print_blockchain(uint32_t start_index, uint32_t end_index) {
m_blockchain.print_blockchain(start_index, end_index);
}

void core::print_blockchain_index() {
m_blockchain.print_blockchain_index();
void core::print_blockchain_index(bool print_all) {
m_blockchain.print_blockchain_index(print_all);
}

void core::print_blockchain_outs(const std::string& file) {
Expand Down
2 changes: 1 addition & 1 deletion src/CryptoNoteCore/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace cn {
//Blockchain& get_blockchain_storage(){return m_blockchain;}
//debug functions
void print_blockchain(uint32_t start_index, uint32_t end_index);
void print_blockchain_index();
void print_blockchain_index(bool print_all);
std::string print_pool(bool short_format);
std::list<cn::tx_memory_pool::TransactionDetails> getMemoryPool() const;
void print_blockchain_outs(const std::string &file);
Expand Down
Loading