Only fetch one collation at a time per relay parent (#3333)

* Only fetch one collation at a time per relay parent

Before a validator would fetch all collations that were advertised to
him. This pr changes the behavior to always just fetch one collation at
a time. If fetching fails, the validator will start fetching one of the
other collations.

* Use enum to be more explicit

* Review comments
This commit is contained in:
Bastian Köcher
2021-06-21 21:51:31 +02:00
committed by GitHub
parent 3d2931ace5
commit 9fa5d28e0b
4 changed files with 406 additions and 691 deletions
@@ -44,7 +44,7 @@ pub use sc_network::config::RequestResponseConfig;
/// All requests that can be sent to the network bridge.
pub mod request;
pub use request::{IncomingRequest, OutgoingRequest, Requests, Recipient, OutgoingResult};
pub use request::{IncomingRequest, OutgoingRequest, Requests, Recipient, OutgoingResult, ResponseSender};
///// Multiplexer for incoming requests.
// pub mod multiplexer;
@@ -29,6 +29,9 @@ use crate::UnifiedReputationChange;
use super::{v1, Protocol};
/// Used by the network to send us a response to a request.
pub type ResponseSender = oneshot::Sender<Result<Vec<u8>, network::RequestFailure>>;
/// Common properties of any `Request`.
pub trait IsRequest {
/// Each request has a corresponding `Response`.
@@ -109,7 +112,7 @@ pub struct OutgoingRequest<Req> {
/// The actual request to send over the wire.
pub payload: Req,
/// Sender which is used by networking to get us back a response.
pub pending_response: oneshot::Sender<Result<Vec<u8>, network::RequestFailure>>,
pub pending_response: ResponseSender,
}
/// Any error that can occur when sending a request.