mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Request based collation fetching (#2621)
* Introduce collation fetching protocol also move to mod.rs * Allow `PeerId`s in requests to network bridge. * Fix availability distribution tests. * Move CompressedPoV to primitives. * Request based collator protocol: validator side - Missing: tests - Collator side - don't connect, if not connected * Fixes. * Basic request based collator side. * Minor fix on collator side. * Don't connect in requests in collation protocol. Also some cleanup. * Fix PoV distribution * Bump substrate * Add back metrics + whitespace fixes. * Add back missing spans. * More cleanup. * Guide update. * Fix tests * Handle results in tests. * Fix weird compilation issue. * Add missing ) * Get rid of dead code. * Get rid of redundant import. * Fix runtime build. * Cleanup. * Fix wasm build. * Format fixes. Thanks @andronik !
This commit is contained in:
@@ -29,7 +29,7 @@ use sc_network::{IfDisconnected, NetworkService, OutboundFailure, RequestFailure
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
peer_set::PeerSet,
|
||||
request_response::{OutgoingRequest, Requests},
|
||||
request_response::{OutgoingRequest, Requests, Recipient},
|
||||
PeerId, UnifiedReputationChange as Rep,
|
||||
};
|
||||
use polkadot_primitives::v1::{Block, Hash};
|
||||
@@ -113,6 +113,7 @@ pub trait Network: Send + 'static {
|
||||
&self,
|
||||
authority_discovery: &mut AD,
|
||||
req: Requests,
|
||||
if_disconnected: IfDisconnected,
|
||||
);
|
||||
|
||||
/// Report a given peer as either beneficial (+) or costly (-) according to the given scalar.
|
||||
@@ -202,6 +203,7 @@ impl Network for Arc<NetworkService<Block, Hash>> {
|
||||
&self,
|
||||
authority_discovery: &mut AD,
|
||||
req: Requests,
|
||||
if_disconnected: IfDisconnected,
|
||||
) {
|
||||
let (
|
||||
protocol,
|
||||
@@ -212,14 +214,18 @@ impl Network for Arc<NetworkService<Block, Hash>> {
|
||||
},
|
||||
) = req.encode_request();
|
||||
|
||||
let peer_id = authority_discovery
|
||||
.get_addresses_by_authority_id(peer)
|
||||
.await
|
||||
.and_then(|addrs| {
|
||||
addrs
|
||||
.into_iter()
|
||||
.find_map(|addr| peer_id_from_multiaddr(&addr))
|
||||
});
|
||||
let peer_id = match peer {
|
||||
Recipient::Peer(peer_id) => Some(peer_id),
|
||||
Recipient::Authority(authority) =>
|
||||
authority_discovery
|
||||
.get_addresses_by_authority_id(authority)
|
||||
.await
|
||||
.and_then(|addrs| {
|
||||
addrs
|
||||
.into_iter()
|
||||
.find_map(|addr| peer_id_from_multiaddr(&addr))
|
||||
}),
|
||||
};
|
||||
|
||||
let peer_id = match peer_id {
|
||||
None => {
|
||||
@@ -244,7 +250,7 @@ impl Network for Arc<NetworkService<Block, Hash>> {
|
||||
protocol.into_protocol_name(),
|
||||
payload,
|
||||
pending_response,
|
||||
IfDisconnected::TryConnect,
|
||||
if_disconnected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user