MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ProcessBlock

Function ProcessBlock

src/test/util/mining.cpp:112–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112COutPoint ProcessBlock(const NodeContext& node, const std::shared_ptr<CBlock>& block)
113{
114 auto& chainman{*Assert(node.chainman)};
115 const auto old_height = WITH_LOCK(chainman.GetMutex(), return chainman.ActiveHeight());
116 bool new_block;
117 BlockValidationStateCatcher bvsc{block->GetHash()};
118 node.validation_signals->RegisterValidationInterface(&bvsc);
119 const bool processed{chainman.ProcessNewBlock(block, true, true, &new_block)};
120 const bool duplicate{!new_block && processed};
121 assert(!duplicate);
122 node.validation_signals->UnregisterValidationInterface(&bvsc);
123 node.validation_signals->SyncWithValidationInterfaceQueue();
124 const bool was_valid{bvsc.m_state && bvsc.m_state->IsValid()};
125 assert(old_height + was_valid == WITH_LOCK(chainman.GetMutex(), return chainman.ActiveHeight()));
126
127 if (was_valid) return {block->vtx[0]->GetHash(), 0};
128 return {};
129}
130
131std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node,
132 const node::BlockCreateOptions& assembler_options)

Callers 7

ProcessMessageMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
sanity_check_snapshotFunction · 0.85
MineBlockFunction · 0.85
SyncMethod · 0.85
BlockConnectedMethod · 0.85

Calls 6

ProcessNewBlockMethod · 0.80
GetHashMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected