Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
#include <attributes.h> | #include <attributes.h> | ||||
#include <cerrno> | #include <cerrno> | ||||
#include <csignal> | #include <csignal> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#endif | #endif | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <functional> | #include <functional> | ||||
#include <optional> | |||||
#include <set> | #include <set> | ||||
static const bool DEFAULT_PROXYRANDOMIZE = true; | static const bool DEFAULT_PROXYRANDOMIZE = true; | ||||
static const bool DEFAULT_REST_ENABLE = false; | static const bool DEFAULT_REST_ENABLE = false; | ||||
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; | static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
// Win32 LevelDB doesn't use filedescriptors, and the ones used for accessing | // Win32 LevelDB doesn't use filedescriptors, and the ones used for accessing | ||||
▲ Show 20 Lines • Show All 2,341 Lines • ▼ Show 20 Lines | #endif | ||||
g_avalanche = std::make_unique<avalanche::Processor>( | g_avalanche = std::make_unique<avalanche::Processor>( | ||||
*node.chain, node.connman.get(), node.peerman.get()); | *node.chain, node.connman.get(), node.peerman.get()); | ||||
if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | ||||
nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | ||||
// If avalanche is enabled and a proof is supplied, make sure it does | // If avalanche is enabled and a proof is supplied, make sure it does | ||||
// not contain garbage. At this point the validity of the utxos cannot | // not contain garbage. At this point the validity of the utxos cannot | ||||
// be checked, so only basic verification is performed. | // be checked, so only basic verification is performed. | ||||
try { | const std::optional<avalanche::Proof> proof = g_avalanche->getProof(); | ||||
avalanche::Proof proof; | |||||
proof = g_avalanche->getProof(); | |||||
if (!proof) { | |||||
LogPrintf("Avalanche is enabled but no proof supplied, the node " | |||||
"will not be able to vote\n"); | |||||
} else { | |||||
avalanche::ProofValidationState proof_state; | avalanche::ProofValidationState proof_state; | ||||
if (!proof.verify(proof_state)) { | if (!proof->verify(proof_state)) { | ||||
switch (proof_state.GetResult()) { | switch (proof_state.GetResult()) { | ||||
case avalanche::ProofValidationResult::NO_STAKE: | case avalanche::ProofValidationResult::NO_STAKE: | ||||
InitError(_("the avalanche proof has no stake")); | InitError(_("the avalanche proof has no stake")); | ||||
return false; | return false; | ||||
case avalanche::ProofValidationResult::DUST_THRESOLD: | case avalanche::ProofValidationResult::DUST_THRESOLD: | ||||
InitError(_("the avalanche proof stake is too low")); | InitError(_("the avalanche proof stake is too low")); | ||||
return false; | return false; | ||||
case avalanche::ProofValidationResult::DUPLICATE_STAKE: | case avalanche::ProofValidationResult::DUPLICATE_STAKE: | ||||
Show All 9 Lines | if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | ||||
"many utxos (max: %u)"), | "many utxos (max: %u)"), | ||||
AVALANCHE_MAX_PROOF_STAKES)); | AVALANCHE_MAX_PROOF_STAKES)); | ||||
return false; | return false; | ||||
default: | default: | ||||
InitError(_("the avalanche proof is invalid")); | InitError(_("the avalanche proof is invalid")); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} catch (const std::runtime_error &e) { | |||||
LogPrintf("Avalanche is enabled but no proof supplied, the node " | |||||
"will not be able to vote\n"); | |||||
} | } | ||||
} | } | ||||
// Step 7: load block chain | // Step 7: load block chain | ||||
fReindex = args.GetBoolArg("-reindex", false); | fReindex = args.GetBoolArg("-reindex", false); | ||||
bool fReindexChainState = args.GetBoolArg("-reindex-chainstate", false); | bool fReindexChainState = args.GetBoolArg("-reindex-chainstate", false); | ||||
▲ Show 20 Lines • Show All 521 Lines • Show Last 20 Lines |