MCPcopy Create free account
hub / github.com/ElementsProject/elements / ValidDepths

Method ValidDepths

src/script/standard.cpp:439–460  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

437}
438
439/*static*/ bool TaprootBuilder::ValidDepths(const std::vector<int>& depths)
440{
441 std::vector<bool> branch;
442 for (int depth : depths) {
443 // This inner loop corresponds to effectively the same logic on branch
444 // as what Insert() performs on the m_branch variable. Instead of
445 // storing a NodeInfo object, just remember whether or not there is one
446 // at that depth.
447 if (depth < 0 || (size_t)depth > TAPROOT_CONTROL_MAX_NODE_COUNT) return false;
448 if ((size_t)depth + 1 < branch.size()) return false;
449 while (branch.size() > (size_t)depth && branch[depth]) {
450 branch.pop_back();
451 if (depth == 0) return false;
452 --depth;
453 }
454 if (branch.size() <= (size_t)depth) branch.resize((size_t)depth + 1);
455 assert(!branch[depth]);
456 branch[depth] = true;
457 }
458 // And this check corresponds to the IsComplete() check on m_branch.
459 return branch.size() == 0 || (branch.size() == 1 && branch[0]);
460}
461
462TaprootBuilder& TaprootBuilder::Add(int depth, const CScript& script, int leaf_version, bool track)
463{

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
pop_backMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected