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>( | std::string avalancheInitError = avalanche::Processor::Init( | ||||
*node.chain, node.connman.get(), node.peerman.get()); | *node.chain, node.connman.get(), node.peerman.get()); | ||||
if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | if (!avalancheInitError.empty()) { | ||||
nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | InitError(_(avalancheInitError.c_str())); | ||||
deadalnix: When you reach that point, you cannot know if or how the string needs to be translated. For… | |||||
// 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"); | |||||
} | } | ||||
if (args.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | |||||
nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE); | |||||
deadalnixUnsubmitted Not Done Inline ActionsYou did not introduce that problem, but this is actually incorrect. It is not because avalanche is enabled on the node that the node is providing a service to the network. For instance, if the node doesn't have a proof attached, then it provide no service to the network. deadalnix: You did not introduce that problem, but this is actually incorrect. It is not because 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 |
When you reach that point, you cannot know if or how the string needs to be translated. For instance, it may have dynamic parameters in it, and not be translatable anymore as a result at this stage.
You want to bubble up a bilingual_str here.
It is also poor design to assign a specific meaning to an empty string. The rest of the codebase returns a bool of a nullable pointer, and you get the errors and warning as out parameters (see LoadWallet for instance).