Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | class Processor::NotificationsHandler | ||||
: public interfaces::Chain::Notifications { | : public interfaces::Chain::Notifications { | ||||
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 && | |||||
!::ChainstateActive().IsInitialBlockDownload()) { | |||||
m_processor->peerManager->getPeerId(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) | ||||
: connman(connmanIn), nodePeerManager(nodePeerManagerIn), | : connman(connmanIn), nodePeerManager(nodePeerManagerIn), | ||||
queryTimeoutDuration(AVALANCHE_DEFAULT_QUERY_TIMEOUT), round(0), | queryTimeoutDuration(AVALANCHE_DEFAULT_QUERY_TIMEOUT), round(0), | ||||
Show All 9 Lines | if (gArgs.IsArgSet("-avaproof")) { | ||||
peerData = std::make_unique<PeerData>(); | peerData = std::make_unique<PeerData>(); | ||||
{ | { | ||||
// The proof. | // The proof. | ||||
CDataStream stream(ParseHex(gArgs.GetArg("-avaproof", "")), | CDataStream stream(ParseHex(gArgs.GetArg("-avaproof", "")), | ||||
SER_NETWORK, 0); | SER_NETWORK, 0); | ||||
stream >> peerData->proof; | stream >> peerData->proof; | ||||
// Ensure the peer manager knows about it. | // Schedule proof registration at the first new block after IBD. | ||||
// FIXME: There is no way to register the proof at this time because | mustRegisterProof = true; | ||||
// we might not have the proper chainstate at the moment. We need to | |||||
// find a way to delay the registration of the proof until after IBD | |||||
// has finished and the chain state is settled. | |||||
// LOCK(cs_peerManager); | |||||
// peerManager->getPeerId(peerData->proof); | |||||
} | } | ||||
// Generate the delegation to the session key. | // Generate the delegation to the session key. | ||||
DelegationBuilder dgb(peerData->proof); | DelegationBuilder dgb(peerData->proof); | ||||
if (sessionKey.GetPubKey() != peerData->proof.getMaster()) { | if (sessionKey.GetPubKey() != peerData->proof.getMaster()) { | ||||
dgb.addLevel(DecodeSecret(gArgs.GetArg("-avamasterkey", "")), | dgb.addLevel(DecodeSecret(gArgs.GetArg("-avamasterkey", "")), | ||||
sessionKey.GetPubKey()); | sessionKey.GetPubKey()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 409 Lines • Show Last 20 Lines |