21 std::shared_ptr<network::PeerManager> pm,
22 std::shared_ptr<crypto::Sr25519Provider> crypto_provider,
23 std::shared_ptr<parachain::ParachainProcessorImpl> processor)
28 "Crypto provider must be initialised!");
29 BOOST_ASSERT_MSG(
pm_,
"Peer manager must be initialised!");
30 BOOST_ASSERT_MSG(
processor_,
"Parachain processor must be initialised!");
36 auto ¶chain_state =
pm_->parachainState();
37 bool const contains_para_hash =
38 (parachain_state.our_view.count(relay_parent) != 0);
40 if (!contains_para_hash) {
41 logger_->warn(
"Advertise collation out of view from peer {}", peer_id);
45 auto const peer_state =
pm_->getPeerState(peer_id);
47 logger_->warn(
"Received collation advertise from unknown peer {}",
52 auto result =
pm_->insert_advertisement(
53 peer_state->get(), parachain_state, std::move(relay_parent));
55 logger_->warn(
"Insert advertisement from {} failed: {}",
57 result.error().message());
63 .relay_parent = relay_parent,
71 auto const peer_state =
pm_->getPeerState(peer_id);
73 logger_->warn(
"Received collation declaration from unknown peer {}:{}",
79 if (peer_state->get().collator_state) {
80 logger_->warn(
"Peer is in collating state {}:{}", peer_id, para_id);
84 auto payload{peer_id.toVector()};
85 payload.insert(payload.end(), {
'C',
'O',
'L',
'L'});
89 signature, gsl::span<uint8_t>(payload), pubkey);
91 logger_->warn(
"Received incorrect collation declaration from {}:{}",
98 pm_->setCollating(peer_id, pubkey, para_id);
102 std::shared_ptr<network::PeerManager>
pm_;
104 std::shared_ptr<parachain::ParachainProcessorImpl>
processor_;
110 :
pm_{std::move(pm)} {
111 BOOST_ASSERT_MSG(
pm_,
"Peer manager must be initialised!");
122 std::shared_ptr<network::PeerManager>
pm_;
129 ParachainObserverImpl::ParachainObserverImpl(
130 std::shared_ptr<network::PeerManager> pm,
131 std::shared_ptr<crypto::Sr25519Provider> crypto_provider,
132 std::shared_ptr<parachain::ParachainProcessorImpl> processor)
133 : collation_observer_impl_{std::make_shared<
135 pm, std::move(crypto_provider), processor)},
137 std::make_shared<observers::ReqCollationObserverImpl>(pm)},
140 "Collation observer must be initialised!");
142 "Fetch collation observer must be initialised!");
143 BOOST_ASSERT_MSG(
processor_,
"Parachain processor must be initialised!");
156 peer_id, std::move(pubkey), std::move(para_id), std::move(signature));
159 outcome::result<network::CollationFetchingResponse>
void onDeclare(libp2p::peer::PeerId const &peer_id, network::CollatorPublicKey pubkey, network::ParachainId para_id, network::Signature signature) override
std::shared_ptr< network::PeerManager > pm_
outcome::result< network::CollationFetchingResponse > OnCollationRequest(network::CollationFetchingRequest request) override
fetch collation protocol observer
std::shared_ptr< crypto::Sr25519Provider > crypto_provider_
crypto::Sr25519PublicKey CollatorPublicKey
libp2p::peer::PeerId PeerId
std::shared_ptr< soralog::Logger > Logger
std::shared_ptr< observers::ReqCollationObserverImpl > req_collation_observer_impl_
outcome::result< network::CollationFetchingResponse > OnCollationRequest(network::CollationFetchingRequest request) override
CollationObserverImpl(std::shared_ptr< network::PeerManager > pm, std::shared_ptr< crypto::Sr25519Provider > crypto_provider, std::shared_ptr< parachain::ParachainProcessorImpl > processor)
std::shared_ptr< network::PeerManager > pm_
void onDeclare(libp2p::peer::PeerId const &peer_id, network::CollatorPublicKey pubkey, network::ParachainId para_id, network::Signature signature) override
std::shared_ptr< parachain::ParachainProcessorImpl > processor_
ReqCollationObserverImpl(std::shared_ptr< network::PeerManager > pm)
std::shared_ptr< parachain::ParachainProcessorImpl > processor_
Logger createLogger(const std::string &tag)
crypto::Sr25519Signature Signature
network::ParachainId para_id
void onAdvertise(libp2p::peer::PeerId const &peer_id, primitives::BlockHash para_hash) override
collation protocol observer
void onAdvertise(libp2p::peer::PeerId const &peer_id, primitives::BlockHash relay_parent) override
~CollationObserverImpl() override=default
std::shared_ptr< observers::CollationObserverImpl > collation_observer_impl_