Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 2,430 Lines • ▼ Show 20 Lines | #endif | ||||
if (args.IsArgSet("-maxuploadtarget")) { | if (args.IsArgSet("-maxuploadtarget")) { | ||||
nMaxOutboundLimit = | nMaxOutboundLimit = | ||||
args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET) * 1024 * | args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET) * 1024 * | ||||
1024; | 1024; | ||||
} | } | ||||
// Step 6.5 (I guess ?): Initialize Avalanche. | // Step 6.5 (I guess ?): Initialize Avalanche. | ||||
g_avalanche = std::make_unique<avalanche::Processor>( | bilingual_str avalancheError; | ||||
*node.chain, node.connman.get(), node.peerman.get()); | g_avalanche = avalanche::Processor::MakeProcessor( | ||||
if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | args, *node.chain, node.connman.get(), node.peerman.get(), | ||||
nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | avalancheError); | ||||
if (!g_avalanche) { | |||||
// If avalanche is enabled and a proof is supplied, make sure it does | InitError(avalancheError); | ||||
// not contain garbage. At this point the validity of the utxos cannot | |||||
// be checked, so only basic verification is performed. | |||||
try { | |||||
avalanche::Proof proof; | |||||
proof = g_avalanche->getProof(); | |||||
avalanche::ProofValidationState proof_state; | |||||
if (!proof.verify(proof_state)) { | |||||
switch (proof_state.GetResult()) { | |||||
case avalanche::ProofValidationResult::NO_STAKE: | |||||
InitError(_("the avalanche proof has no stake")); | |||||
return false; | |||||
case avalanche::ProofValidationResult::DUST_THRESOLD: | |||||
InitError(_("the avalanche proof stake is too low")); | |||||
return false; | |||||
case avalanche::ProofValidationResult::DUPLICATE_STAKE: | |||||
InitError( | |||||
_("the avalanche proof has duplicated stake")); | |||||
return false; | return false; | ||||
case avalanche::ProofValidationResult::INVALID_SIGNATURE: | |||||
InitError(_("the avalanche proof has invalid stake " | |||||
"signatures")); | |||||
return false; | |||||
case avalanche::ProofValidationResult::TOO_MANY_UTXOS: | |||||
InitError(strprintf(_("the avalanche proof has too " | |||||
"many utxos (max: %u)"), | |||||
AVALANCHE_MAX_PROOF_STAKES)); | |||||
return false; | |||||
default: | |||||
InitError(_("the avalanche proof is invalid")); | |||||
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"); | |||||
} | } | ||||
if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | |||||
nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | |||||
} | } | ||||
// 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); | ||||
// cache size calculations | // cache size calculations | ||||
▲ Show 20 Lines • Show All 520 Lines • Show Last 20 Lines |