Filters and block RPCs for the light client#5320
Conversation
| use futures::stream::{self, Stream}; | ||
| use util::H2048; | ||
|
|
||
| // early exit for "to" block before "from" block. |
There was a problem hiding this comment.
comment doesn't accurately describe logic below it
| BlockId::Latest | BlockId::Pending => { | ||
| let best = self.client.best_block_header(); | ||
| let chain_info = self.client.chain_info(); | ||
| if best.number() != chain_info.best_block_number || best.hash() != chain_info.best_block_hash { |
There was a problem hiding this comment.
am i missing something here? looks to just be comparing self.client.chain_info() with self.client.best_block_header()...
There was a problem hiding this comment.
Good catch, seems like it got mangled a bit when I was running over that part of the code.
| BlockId::Number(x) => Some(x), | ||
| }; | ||
|
|
||
| if block_number(filter.to_block) < block_number(filter.from_block) { |
There was a problem hiding this comment.
does this really play well with Option's ordering? what if to_block is None? is it not better to fail ealy if either are None?
There was a problem hiding this comment.
It's sort of a trade-off, but actually neither from_block nor to_block is ever a hash where these are invoked, so these are both always Some.
The alternative would be to pass a rpc::Filter instead of an EthcoreFilter, but then the logic for setting the to and from blocks would have to be duplicated.
There was a problem hiding this comment.
would suggest using either an alternative type which doesn't given the option of providing a Hash, or otherwise bomb early with an Err if either is None .
Adds minimal implementations of log/filter RPCs for the light client.
Doesn't fetch any headers from network, just bails if they're not available locally.