return only complete headers responses
This commit is contained in:
parent
391eb4b66c
commit
64342d200c
@ -62,7 +62,7 @@ pub trait Provider: Send + Sync {
|
|||||||
HashOrNumber::Number(start_num) => start_num,
|
HashOrNumber::Number(start_num) => start_num,
|
||||||
HashOrNumber::Hash(hash) => match self.block_header(BlockId::Hash(hash)) {
|
HashOrNumber::Hash(hash) => match self.block_header(BlockId::Hash(hash)) {
|
||||||
None => {
|
None => {
|
||||||
trace!(target: "les_provider", "Unknown block hash {} requested", hash);
|
trace!(target: "pip_provider", "Unknown block hash {} requested", hash);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(header) => {
|
Some(header) => {
|
||||||
@ -91,8 +91,12 @@ pub trait Provider: Send + Sync {
|
|||||||
.flat_map(|x| x)
|
.flat_map(|x| x)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
if headers.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
Some(::request::HeadersResponse { headers: headers })
|
Some(::request::HeadersResponse { headers: headers })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a block header by id.
|
/// Get a block header by id.
|
||||||
fn block_header(&self, id: BlockId) -> Option<encoded::Header>;
|
fn block_header(&self, id: BlockId) -> Option<encoded::Header>;
|
||||||
@ -182,7 +186,7 @@ impl<T: ProvingBlockChainClient + ?Sized> Provider for T {
|
|||||||
let cht_number = match cht::block_to_cht_number(req.num) {
|
let cht_number = match cht::block_to_cht_number(req.num) {
|
||||||
Some(cht_num) => cht_num,
|
Some(cht_num) => cht_num,
|
||||||
None => {
|
None => {
|
||||||
debug!(target: "les_provider", "Requested CHT proof with invalid block number");
|
debug!(target: "pip_provider", "Requested CHT proof with invalid block number");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -230,7 +234,7 @@ impl<T: ProvingBlockChainClient + ?Sized> Provider for T {
|
|||||||
}),
|
}),
|
||||||
Ok(None) => None,
|
Ok(None) => None,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!(target: "les_provider", "Error looking up number in freshly-created CHT: {}", e);
|
debug!(target: "pip_provider", "Error looking up number in freshly-created CHT: {}", e);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user