Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 2,426 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>( | avalanche::Processor *proc = avalanche::Processor::MakeProcessor( | ||||
deadalnix: This temporary doesn't seems necessary. | |||||
*node.chain, node.connman.get(), node.peerman.get()); | *node.chain, node.connman.get(), node.peerman.get()); | ||||
if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | if (!proc) { | ||||
nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | |||||
// 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 | |||||
// be checked, so only basic verification is performed. | |||||
const avalanche::Proof *proof = g_avalanche->getLocalProof(); | |||||
if (proof) { | |||||
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; | |||||
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; | return false; | ||||
default: | |||||
InitError(_("the avalanche proof is invalid")); | |||||
return false; | |||||
} | |||||
} | |||||
} else { | |||||
LogPrintf("Avalanche is enabled but no proof supplied, the node " | |||||
"will not be able to vote\n"); | |||||
} | } | ||||
g_avalanche.reset(proc); | |||||
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 |
This temporary doesn't seems necessary.