Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,738 Lines • ▼ Show 20 Lines | CSerializedNetMsg msg = CNetMsgMaker(peer.GetCommonVersion()) | ||||
.Make(NetMsgType::CFCHECKPT, filter_type_ser, | .Make(NetMsgType::CFCHECKPT, filter_type_ser, | ||||
stop_index->GetBlockHash(), headers); | stop_index->GetBlockHash(), headers); | ||||
connman.PushMessage(&peer, std::move(msg)); | connman.PushMessage(&peer, std::move(msg)); | ||||
} | } | ||||
bool IsAvalancheMessageType(const std::string &msg_type) { | bool IsAvalancheMessageType(const std::string &msg_type) { | ||||
return msg_type == NetMsgType::AVAHELLO || | return msg_type == NetMsgType::AVAHELLO || | ||||
msg_type == NetMsgType::AVAPOLL || | msg_type == NetMsgType::AVAPOLL || | ||||
msg_type == NetMsgType::AVARESPONSE; | msg_type == NetMsgType::AVARESPONSE || | ||||
msg_type == NetMsgType::AVAPROOF; | |||||
} | } | ||||
void PeerManager::ProcessMessage(const Config &config, CNode &pfrom, | void PeerManager::ProcessMessage(const Config &config, CNode &pfrom, | ||||
const std::string &msg_type, | const std::string &msg_type, | ||||
CDataStream &vRecv, | CDataStream &vRecv, | ||||
const std::chrono::microseconds time_received, | const std::chrono::microseconds time_received, | ||||
const std::atomic<bool> &interruptMsgProc) { | const std::atomic<bool> &interruptMsgProc) { | ||||
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", | LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", | ||||
▲ Show 20 Lines • Show All 1,361 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAHELLO) { | ||||
const avalanche::ProofId proofid(delegation.getProofId()); | const avalanche::ProofId proofid(delegation.getProofId()); | ||||
if (!AlreadyHaveProof(proofid)) { | if (!AlreadyHaveProof(proofid)) { | ||||
const bool preferred = isPreferredDownloadPeer(pfrom); | const bool preferred = isPreferredDownloadPeer(pfrom); | ||||
LOCK(cs_proofrequest); | LOCK(cs_proofrequest); | ||||
AddProofAnnouncement(pfrom, proofid, | AddProofAnnouncement(pfrom, proofid, | ||||
GetTime<std::chrono::microseconds>(), | GetTime<std::chrono::microseconds>(), | ||||
preferred); | preferred); | ||||
} | } | ||||
return; | |||||
} | |||||
if (msg_type == NetMsgType::AVAPROOF) { | |||||
if (!gArgs.GetBoolArg("-exchangeavaproofs", | |||||
AVALANCHE_DEFAULT_SHARE_PROOFS)) { | |||||
return; | |||||
} | |||||
auto proof = std::make_shared<avalanche::Proof>(); | |||||
vRecv >> *proof; | |||||
if (pfrom.m_avalanche_state && | |||||
proof->getId() == | |||||
pfrom.m_avalanche_state->delegation.getProofId() && | |||||
g_avalanche->addNode(pfrom.GetId(), proof, | |||||
pfrom.m_avalanche_state->delegation)) { | |||||
LogPrint(BCLog::NET, "added avalanche node=%d\n", pfrom.GetId()); | |||||
} else if (g_avalanche->addProof(proof)) { | |||||
LogPrint(BCLog::NET, "added new proof id=%s\n", | |||||
proof->getId().GetHex()); | |||||
} | |||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::AVAPOLL) { | if (msg_type == NetMsgType::AVAPOLL) { | ||||
auto now = std::chrono::steady_clock::now(); | auto now = std::chrono::steady_clock::now(); | ||||
int64_t cooldown = | int64_t cooldown = | ||||
gArgs.GetArg("-avacooldown", AVALANCHE_DEFAULT_COOLDOWN); | gArgs.GetArg("-avacooldown", AVALANCHE_DEFAULT_COOLDOWN); | ||||
▲ Show 20 Lines • Show All 1,606 Lines • Show Last 20 Lines |