mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-16 08:54:19 +02:00
refactor: Enable -Wswitch in exhaustive switch
Also, apply the comment according to the dev notes. Also, modify the dev notes to give a lambda-wrapped example. Can be reviewed via --ignore-all-space Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -41,12 +41,13 @@ static void VerifyScriptBench(benchmark::Bench& bench, ScriptType script_type)
|
||||
keystore.pubkeys.emplace(key_id, pubkey);
|
||||
|
||||
// Create crediting and spending transactions with provided input type
|
||||
CTxDestination dest;
|
||||
switch (script_type) {
|
||||
case ScriptType::P2WPKH: dest = WitnessV0KeyHash(pubkey); break;
|
||||
case ScriptType::P2TR: dest = WitnessV1Taproot(XOnlyPubKey{pubkey}); break;
|
||||
default: assert(false);
|
||||
}
|
||||
const auto dest{[&]() -> CTxDestination {
|
||||
switch (script_type) {
|
||||
case ScriptType::P2WPKH: return WitnessV0KeyHash(pubkey);
|
||||
case ScriptType::P2TR: return WitnessV1Taproot(XOnlyPubKey{pubkey});
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}()};
|
||||
const CMutableTransaction& txCredit = BuildCreditingTransaction(GetScriptForDestination(dest), 1);
|
||||
CMutableTransaction txSpend = BuildSpendingTransaction(/*scriptSig=*/{}, /*scriptWitness=*/{}, CTransaction(txCredit));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user