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

Fix checkpoints loading | Huge sync speed boost #272

Merged
merged 4 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,6 @@ namespace cn
{
loadBlockchainIndices();
}

m_checkpoints.load_checkpoints();
logger(logging::INFO) << "Loading checkpoints";
m_checkpoints.load_checkpoints_from_dns();
logger(logging::INFO) << "Loading DNS checkpoints";
}
else
{
Expand Down
7 changes: 4 additions & 3 deletions src/CryptoNoteCore/Checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ bool Checkpoints::add_checkpoint(uint32_t height, const std::string &hash_str) {
}

if (!(0 == m_points.count(height))) {
logger(ERROR) << "<< Checkpoints.cpp << " << "Incorrect hash in checkpoints";
logger(DEBUGGING) << "Checkpoint already exists for height " << height;
return false;
}

m_points[height] = h;

return true;
}
//---------------------------------------------------------------------------
Expand Down Expand Up @@ -133,7 +134,7 @@ bool Checkpoints::load_checkpoints_from_dns()
logger(DEBUGGING) << "<< Checkpoints.cpp << " << "Checkpoint already exists for height: " << height << ". Ignoring DNS checkpoint.";
} else {
add_checkpoint(height, hash_str);
logger(INFO) << "<< Checkpoints.cpp << " << "Added DNS checkpoint: " << height_str << ":" << hash_str;
logger(DEBUGGING) << "<< Checkpoints.cpp << " << "Added DNS checkpoint: " << height_str << ":" << hash_str;
}
}

Expand Down
15 changes: 14 additions & 1 deletion src/Daemon/Daemon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2016-2018, The Karbo developers
// Copyright (c) 2016-2022, The Karbo developers
// Copyright (c) 2017-2018 The Circle Foundation & Conceal Devs
// Copyright (c) 2018-2022 Conceal Network & Conceal Devs
//
Expand All @@ -16,6 +16,8 @@
#include "Common/SignalHandler.h"
#include "Common/PathTools.h"
#include "crypto/hash.h"
#include "CryptoNoteConfig.h"
#include "CryptoNoteCore/Checkpoints.h"
#include "CryptoNoteCore/Core.h"
#include "CryptoNoteCore/CoreConfig.h"
#include "CryptoNoteCore/CryptoNoteTools.h"
Expand Down Expand Up @@ -278,6 +280,17 @@ int main(int argc, char* argv[])
cn::Currency currency = currencyBuilder.currency();
cn::core ccore(currency, nullptr, logManager, vm["enable-blockchain-indexes"].as<bool>(), vm["enable-autosave"].as<bool>());

cn::Checkpoints checkpoints(logManager);
for (const auto& cp : cn::CHECKPOINTS) {
checkpoints.add_checkpoint(cp.height, cp.blockId);
}

checkpoints.load_checkpoints_from_dns();

if (!testnet_mode) {
ccore.set_checkpoints(std::move(checkpoints));
}

CoreConfig coreConfig;
coreConfig.init(vm);
NetNodeConfig netNodeConfig;
Expand Down