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 state request protocol, refusing incoming requests.

Examples found in repository?
src/state_request_handler.rs (lines 137-145)
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	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)
	}