Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | class Processor::NotificationsHandler | ||||
Processor *m_processor; | Processor *m_processor; | ||||
public: | public: | ||||
NotificationsHandler(Processor *p) : m_processor(p) {} | NotificationsHandler(Processor *p) : m_processor(p) {} | ||||
void updatedBlockTip() override { | void updatedBlockTip() override { | ||||
LOCK(m_processor->cs_peerManager); | LOCK(m_processor->cs_peerManager); | ||||
if (m_processor->mustRegisterProof && | if (m_processor->peerData && m_processor->peerData->proof) { | ||||
!::ChainstateActive().IsInitialBlockDownload()) { | m_processor->peerManager->registerProof( | ||||
m_processor->peerManager->getPeerId(m_processor->peerData->proof); | m_processor->peerData->proof); | ||||
m_processor->mustRegisterProof = false; | |||||
} | } | ||||
m_processor->peerManager->updatedBlockTip(); | m_processor->peerManager->updatedBlockTip(); | ||||
} | } | ||||
}; | }; | ||||
Processor::Processor(interfaces::Chain &chain, CConnman *connmanIn, | Processor::Processor(interfaces::Chain &chain, CConnman *connmanIn, | ||||
NodePeerManager *nodePeerManagerIn, | NodePeerManager *nodePeerManagerIn, | ||||
std::unique_ptr<PeerData> peerDataIn, CKey sessionKeyIn) | std::unique_ptr<PeerData> peerDataIn, CKey sessionKeyIn) | ||||
: connman(connmanIn), nodePeerManager(nodePeerManagerIn), | : connman(connmanIn), nodePeerManager(nodePeerManagerIn), | ||||
queryTimeoutDuration(AVALANCHE_DEFAULT_QUERY_TIMEOUT), round(0), | queryTimeoutDuration(AVALANCHE_DEFAULT_QUERY_TIMEOUT), round(0), | ||||
peerManager(std::make_unique<PeerManager>()), | peerManager(std::make_unique<PeerManager>()), | ||||
peerData(std::move(peerDataIn)), sessionKey(std::move(sessionKeyIn)), | peerData(std::move(peerDataIn)), sessionKey(std::move(sessionKeyIn)) { | ||||
// Schedule proof registration at the first new block after IBD. | |||||
// FIXME: get rid of this flag | |||||
mustRegisterProof(!!peerData) { | |||||
// 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() { | ||||
chainNotificationsHandler.reset(); | chainNotificationsHandler.reset(); | ||||
stopEventLoop(); | stopEventLoop(); | ||||
▲ Show 20 Lines • Show All 527 Lines • Show Last 20 Lines |