cfxcore/sync/message/
get_terminal_block_hashes_response.rs1use crate::{
6 message::RequestId,
7 sync::{
8 message::{Context, Handleable},
9 Error,
10 },
11};
12use cfx_types::H256;
13use rlp_derive::{RlpDecodable, RlpEncodable};
14
15#[derive(Debug, PartialEq, RlpDecodable, RlpEncodable)]
16pub struct GetTerminalBlockHashesResponse {
17 pub request_id: RequestId,
18 pub hashes: Vec<H256>,
19}
20
21impl Handleable for GetTerminalBlockHashesResponse {
22 fn handle(self, ctx: &Context) -> Result<(), Error> {
23 debug!("on_terminal_block_hashes_response, msg=:{:?}", self);
24
25 ctx.match_request(self.request_id)?;
26
27 let missing_hash = self
28 .hashes
29 .iter()
30 .filter(|x| !ctx.manager.graph.contains_block_header(&x))
31 .cloned()
32 .collect::<Vec<H256>>();
33 ctx.manager.request_block_headers(
34 ctx.io,
35 Some(ctx.node_id.clone()),
36 missing_hash,
37 true, );
39
40 Ok(())
41 }
42}