Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,736 Lines • ▼ Show 20 Lines | switch (inv.type) { | ||||
LOCK(g_cs_recent_confirmed_transactions); | LOCK(g_cs_recent_confirmed_transactions); | ||||
if (g_recent_confirmed_transactions->contains(txid)) { | if (g_recent_confirmed_transactions->contains(txid)) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return recentRejects->contains(txid) || mempool.exists(txid); | return recentRejects->contains(txid) || mempool.exists(txid); | ||||
} | } | ||||
case MSG_AVA_PROOF: { | |||||
if (!gArgs.GetBoolArg("-enableavalanche", | |||||
AVALANCHE_DEFAULT_ENABLED)) { | |||||
// We are not interested, just say we already got it | |||||
return true; | |||||
} | |||||
const avalanche::ProofId proofid(inv.hash); | |||||
return g_avalanche->getProof(proofid) != nullptr; | |||||
} | |||||
case MSG_BLOCK: | case MSG_BLOCK: | ||||
return LookupBlockIndex(BlockHash(inv.hash)) != nullptr; | return LookupBlockIndex(BlockHash(inv.hash)) != nullptr; | ||||
} | } | ||||
// Don't know what it is, just say we already got one | // Don't know what it is, just say we already got one | ||||
return true; | return true; | ||||
} | } | ||||
void RelayTransaction(const TxId &txid, const CConnman &connman) { | void RelayTransaction(const TxId &txid, const CConnman &connman) { | ||||
▲ Show 20 Lines • Show All 900 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,320 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAHELLO) { | ||||
Misbehaving(pfrom, 100, "invalid-delegation"); | Misbehaving(pfrom, 100, "invalid-delegation"); | ||||
return; | return; | ||||
} | } | ||||
SchnorrSig sig; | SchnorrSig sig; | ||||
verifier >> sig; | verifier >> sig; | ||||
} | } | ||||
if (msg_type == NetMsgType::AVAPROOF) { | |||||
// Read the proof. | |||||
avalanche::Proof proof; | |||||
vRecv >> proof; | |||||
if (!g_avalanche->addProof(std::move(proof)) && | |||||
!g_avalanche->getProof(proof.getId())) { | |||||
// We didn't add it, and it is not because we already have it. | |||||
// It must be bad. | |||||
Misbehaving(pfrom, 100, "invalid-proof"); | |||||
} | |||||
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); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
auto &node_state = State(pfrom.GetId())->m_avalanche_state; | auto &node_state = State(pfrom.GetId())->m_avalanche_state; | ||||
▲ Show 20 Lines • Show All 1,584 Lines • Show Last 20 Lines |