pub fn generate_protocol_config<Hash: AsRef<[u8]>>(
    protocol_id: &ProtocolId,
    genesis_hash: Hash,
    fork_id: Option<&str>
) -> ProtocolConfig
Expand description

Generates a ProtocolConfig for the block request protocol, refusing incoming requests.

Examples found in repository?
src/block_request_handler.rs (lines 157-165)
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
	pub fn new(
		protocol_id: &ProtocolId,
		fork_id: Option<&str>,
		client: Arc<Client>,
		num_peer_hint: usize,
	) -> (Self, ProtocolConfig) {
		// Reserve enough request slots for one request per peer when we are at the maximum
		// number of peers.
		let (tx, request_receiver) = mpsc::channel(num_peer_hint);

		let mut protocol_config = generate_protocol_config(
			protocol_id,
			client
				.block_hash(0u32.into())
				.ok()
				.flatten()
				.expect("Genesis block exists; qed"),
			fork_id,
		);
		protocol_config.inbound_queue = Some(tx);

		let capacity =
			NonZeroUsize::new(num_peer_hint.max(1) * 2).expect("cache capacity is not zero");
		let seen_requests = LruCache::new(capacity);

		(Self { client, request_receiver, seen_requests }, protocol_config)
	}