Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | public: | ||||
READWRITE(response); | READWRITE(response); | ||||
READWRITE(sig); | READWRITE(sig); | ||||
} | } | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
void Processor::sendResponse(CNode *pfrom, Response response) const { | void Processor::sendResponse(CNode *pfrom, Response response) const { | ||||
connman->PushMessage( | connman->PushMessage( | ||||
pfrom, CNetMsgMaker(pfrom->GetSendVersion()) | pfrom, CNetMsgMaker(pfrom->GetCommonVersion()) | ||||
.Make(NetMsgType::AVARESPONSE, | .Make(NetMsgType::AVARESPONSE, | ||||
TCPResponse(std::move(response), sessionKey))); | TCPResponse(std::move(response), sessionKey))); | ||||
} | } | ||||
bool Processor::registerVotes(NodeId nodeid, const Response &response, | bool Processor::registerVotes(NodeId nodeid, const Response &response, | ||||
std::vector<BlockUpdate> &updates) { | std::vector<BlockUpdate> &updates) { | ||||
{ | { | ||||
// Save the time at which we can query again. | // Save the time at which we can query again. | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | std::array<uint8_t, 64> sig; | ||||
hasher << pfrom->nRemoteExtraEntropy; | hasher << pfrom->nRemoteExtraEntropy; | ||||
const uint256 hash = hasher.GetHash(); | const uint256 hash = hasher.GetHash(); | ||||
if (!sessionKey.SignSchnorr(hash, sig)) { | if (!sessionKey.SignSchnorr(hash, sig)) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()) | connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()) | ||||
.Make(NetMsgType::AVAHELLO, | .Make(NetMsgType::AVAHELLO, | ||||
Hello(peerData->delegation, sig))); | Hello(peerData->delegation, sig))); | ||||
return true; | return true; | ||||
} | } | ||||
bool Processor::startEventLoop(CScheduler &scheduler) { | bool Processor::startEventLoop(CScheduler &scheduler) { | ||||
return eventLoop.startEventLoop( | return eventLoop.startEventLoop( | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | do { | ||||
{pnode->GetId(), current_round, timeout, invs}); | {pnode->GetId(), current_round, timeout, invs}); | ||||
// Set the timeout. | // Set the timeout. | ||||
LOCK(cs_peerManager); | LOCK(cs_peerManager); | ||||
peerManager->updateNextRequestTime(pnode->GetId(), timeout); | peerManager->updateNextRequestTime(pnode->GetId(), timeout); | ||||
} | } | ||||
// Send the query to the node. | // Send the query to the node. | ||||
connman->PushMessage( | connman->PushMessage( | ||||
pnode, CNetMsgMaker(pnode->GetSendVersion()) | pnode, CNetMsgMaker(pnode->GetCommonVersion()) | ||||
.Make(NetMsgType::AVAPOLL, | .Make(NetMsgType::AVAPOLL, | ||||
Poll(current_round, std::move(invs)))); | Poll(current_round, std::move(invs)))); | ||||
return true; | return true; | ||||
}); | }); | ||||
// Success! | // Success! | ||||
if (hasSent) { | if (hasSent) { | ||||
return; | return; | ||||
Show All 14 Lines |