-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment doesn't accurately describe logic below it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should now.
rpc/src/v1/impls/light/eth.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, seems like it got mangled a bit when I was running over that part of the code.
rpc/src/v1/impls/light/eth.rs
Outdated
BlockId::Number(x) => Some(x), | ||
}; | ||
|
||
if block_number(filter.to_block) < block_number(filter.from_block) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.