Skip to content

Commit

Permalink
Merge pull request #272 from aivve/fix/checkpoints
Browse files Browse the repository at this point in the history
Fix checkpoints loading | Huge sync speed boost
  • Loading branch information
krypt0x committed Feb 12, 2022
2 parents d6141d8 + b51a624 commit 6f1e6ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
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

0 comments on commit 6f1e6ad

Please sign in to comment.