Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 3,624 Lines • ▼ Show 20 Lines | if (strCommand == NetMsgType::AVARESPONSE && !fImporting && !fReindex && | ||||
gArgs.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | gArgs.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | ||||
// As long as QUIC is not implemented, we need to sign response and | // As long as QUIC is not implemented, we need to sign response and | ||||
// verify response's signatures in order to avoid any manipulation of | // verify response's signatures in order to avoid any manipulation of | ||||
// messages at the transport level. | // messages at the transport level. | ||||
CHashVerifier<CDataStream> verifier(&vRecv); | CHashVerifier<CDataStream> verifier(&vRecv); | ||||
AvalancheResponse response; | AvalancheResponse response; | ||||
verifier >> response; | verifier >> response; | ||||
if (!g_avalanche->forNode( | if (!g_avalanche->forNode(pfrom->GetId(), [&](const AvalancheNode &n) { | ||||
pfrom->GetId(), [&](const AvalancheProcessor::Node &n) { | |||||
std::array<uint8_t, 64> sig; | std::array<uint8_t, 64> sig; | ||||
vRecv >> sig; | vRecv >> sig; | ||||
// Unfortunately, the verify API require a vector. | // Unfortunately, the verify API require a vector. | ||||
std::vector<uint8_t> vchSig{sig.begin(), sig.end()}; | std::vector<uint8_t> vchSig{sig.begin(), sig.end()}; | ||||
return n.pubkey.VerifySchnorr(verifier.GetHash(), vchSig); | return n.pubkey.VerifySchnorr(verifier.GetHash(), vchSig); | ||||
})) { | })) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
Misbehaving(pfrom, 100, "invalid-ava-response-signature"); | Misbehaving(pfrom, 100, "invalid-ava-response-signature"); | ||||
return true; | return true; | ||||
} | } | ||||
std::vector<AvalancheBlockUpdate> updates; | std::vector<AvalancheBlockUpdate> updates; | ||||
if (!g_avalanche->registerVotes(pfrom->GetId(), response, updates)) { | if (!g_avalanche->registerVotes(pfrom->GetId(), response, updates)) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 1,437 Lines • Show Last 20 Lines |