Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | void updatedBlockTip() override { | ||||
m_processor->peerData->proof); | m_processor->peerData->proof); | ||||
} | } | ||||
m_processor->peerManager->updatedBlockTip(); | m_processor->peerManager->updatedBlockTip(); | ||||
} | } | ||||
}; | }; | ||||
Processor::Processor(interfaces::Chain &chain, CConnman *connmanIn, | Processor::Processor(interfaces::Chain &chain, CConnman *connmanIn, | ||||
std::unique_ptr<PeerData> peerDataIn, CKey sessionKeyIn) | std::unique_ptr<PeerData> peerDataIn, CKey sessionKeyIn, | ||||
: connman(connmanIn), queryTimeoutDuration(AVALANCHE_DEFAULT_QUERY_TIMEOUT), | std::chrono::milliseconds queryTimeoutDurationIn) | ||||
: connman(connmanIn), queryTimeoutDuration(queryTimeoutDurationIn), | |||||
round(0), peerManager(std::make_unique<PeerManager>()), | round(0), peerManager(std::make_unique<PeerManager>()), | ||||
peerData(std::move(peerDataIn)), sessionKey(std::move(sessionKeyIn)) { | peerData(std::move(peerDataIn)), sessionKey(std::move(sessionKeyIn)) { | ||||
// Make sure we get notified of chain state changes. | // Make sure we get notified of chain state changes. | ||||
chainNotificationsHandler = | chainNotificationsHandler = | ||||
chain.handleNotifications(std::make_shared<NotificationsHandler>(this)); | chain.handleNotifications(std::make_shared<NotificationsHandler>(this)); | ||||
} | } | ||||
Processor::~Processor() { | Processor::~Processor() { | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (argsman.IsArgSet("-avaproof")) { | ||||
peerData->delegation = dgb->build(); | peerData->delegation = dgb->build(); | ||||
if (!VerifyDelegation(peerData->delegation, sessionPubKey, error)) { | if (!VerifyDelegation(peerData->delegation, sessionPubKey, error)) { | ||||
// error is set by VerifyDelegation | // error is set by VerifyDelegation | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
} | } | ||||
std::chrono::milliseconds queryTimeout = std::chrono::milliseconds{ | |||||
gArgs.GetArg("-avaquerytimeout", | |||||
count_microseconds(AVALANCHE_DEFAULT_QUERY_TIMEOUT))}; | |||||
// We can't use std::make_unique with a private constructor | // We can't use std::make_unique with a private constructor | ||||
return std::unique_ptr<Processor>(new Processor( | return std::unique_ptr<Processor>( | ||||
chain, connman, std::move(peerData), std::move(sessionKey))); | new Processor(chain, connman, std::move(peerData), | ||||
std::move(sessionKey), queryTimeout)); | |||||
} | } | ||||
bool Processor::addBlockToReconcile(const CBlockIndex *pindex) { | bool Processor::addBlockToReconcile(const CBlockIndex *pindex) { | ||||
bool isAccepted; | bool isAccepted; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (!IsWorthPolling(pindex)) { | if (!IsWorthPolling(pindex)) { | ||||
▲ Show 20 Lines • Show All 476 Lines • Show Last 20 Lines |