Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 3,923 Lines • ▼ Show 20 Lines | void PeerManagerImpl::ProcessHeadersMessage(const Config &config, CNode &pfrom, | ||||
// which can be processed. | // which can be processed. | ||||
// If we don't have the last header, then this peer will have given us | // If we don't have the last header, then this peer will have given us | ||||
// something new (if these headers are valid). | // something new (if these headers are valid). | ||||
bool received_new_header{last_received_header == nullptr}; | bool received_new_header{last_received_header == nullptr}; | ||||
// Now process all the headers. | // Now process all the headers. | ||||
BlockValidationState state; | BlockValidationState state; | ||||
if (!m_chainman.ProcessNewBlockHeaders( | if (!m_chainman.ProcessNewBlockHeaders(headers, /*min_pow_checked=*/true, | ||||
config, headers, /*min_pow_checked=*/true, state, &pindexLast)) { | state, &pindexLast)) { | ||||
if (state.IsInvalid()) { | if (state.IsInvalid()) { | ||||
MaybePunishNodeForBlock(pfrom.GetId(), state, via_compact_block, | MaybePunishNodeForBlock(pfrom.GetId(), state, via_compact_block, | ||||
"invalid header received"); | "invalid header received"); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
Assume(pindexLast); | Assume(pindexLast); | ||||
▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | static uint32_t getAvalancheVoteForProof(const avalanche::ProofId &id) { | ||||
}); | }); | ||||
}; | }; | ||||
void PeerManagerImpl::ProcessBlock(const Config &config, CNode &node, | void PeerManagerImpl::ProcessBlock(const Config &config, CNode &node, | ||||
const std::shared_ptr<const CBlock> &block, | const std::shared_ptr<const CBlock> &block, | ||||
bool force_processing, | bool force_processing, | ||||
bool min_pow_checked) { | bool min_pow_checked) { | ||||
bool new_block{false}; | bool new_block{false}; | ||||
m_chainman.ProcessNewBlock(config, block, force_processing, min_pow_checked, | m_chainman.ProcessNewBlock(block, force_processing, min_pow_checked, | ||||
&new_block); | &new_block); | ||||
if (new_block) { | if (new_block) { | ||||
node.m_last_block_time = GetTime<std::chrono::seconds>(); | node.m_last_block_time = GetTime<std::chrono::seconds>(); | ||||
} else { | } else { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
mapBlockSource.erase(block->GetHash()); | mapBlockSource.erase(block->GetHash()); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,120 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::CMPCTBLOCK) { | ||||
if (!m_chainman.m_blockman.LookupBlockIndex( | if (!m_chainman.m_blockman.LookupBlockIndex( | ||||
cmpctblock.header.GetHash())) { | cmpctblock.header.GetHash())) { | ||||
received_new_header = true; | received_new_header = true; | ||||
} | } | ||||
} | } | ||||
const CBlockIndex *pindex = nullptr; | const CBlockIndex *pindex = nullptr; | ||||
BlockValidationState state; | BlockValidationState state; | ||||
if (!m_chainman.ProcessNewBlockHeaders(config, {cmpctblock.header}, | if (!m_chainman.ProcessNewBlockHeaders({cmpctblock.header}, | ||||
/*min_pow_checked=*/true, state, | /*min_pow_checked=*/true, state, | ||||
&pindex)) { | &pindex)) { | ||||
if (state.IsInvalid()) { | if (state.IsInvalid()) { | ||||
MaybePunishNodeForBlock(pfrom.GetId(), state, | MaybePunishNodeForBlock(pfrom.GetId(), state, | ||||
/*via_compact_block*/ true, | /*via_compact_block*/ true, | ||||
"invalid header via cmpctblock"); | "invalid header via cmpctblock"); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,886 Lines • Show Last 20 Lines |