fixed eth_getLogs
This commit is contained in:
parent
032d29ec86
commit
8340f135fc
@ -61,7 +61,6 @@ impl<F, T> PollManager<F, T> where T: Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implementation is always using `poll_mut`
|
// Implementation is always using `poll_mut`
|
||||||
#[cfg(test)]
|
|
||||||
/// Get a reference to stored poll filter
|
/// Get a reference to stored poll filter
|
||||||
pub fn poll(&mut self, id: &PollId) -> Option<&F> {
|
pub fn poll(&mut self, id: &PollId) -> Option<&F> {
|
||||||
self.polls.prune();
|
self.polls.prune();
|
||||||
|
@ -636,10 +636,11 @@ impl<C, M> EthFilter for EthFilterClient<C, M>
|
|||||||
|
|
||||||
to_value(&diff)
|
to_value(&diff)
|
||||||
},
|
},
|
||||||
PollFilter::Logs(ref mut block_number, ref mut filter) => {
|
PollFilter::Logs(ref mut block_number, ref filter) => {
|
||||||
|
let mut filter = filter.clone();
|
||||||
filter.from_block = BlockId::Number(*block_number);
|
filter.from_block = BlockId::Number(*block_number);
|
||||||
filter.to_block = BlockId::Latest;
|
filter.to_block = BlockId::Latest;
|
||||||
let logs = client.logs(filter.clone())
|
let logs = client.logs(filter)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(From::from)
|
.map(From::from)
|
||||||
.collect::<Vec<Log>>();
|
.collect::<Vec<Log>>();
|
||||||
@ -654,6 +655,27 @@ impl<C, M> EthFilter for EthFilterClient<C, M>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn filter_logs(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
from_params::<(Index,)>(params)
|
||||||
|
.and_then(|(index,)| {
|
||||||
|
let mut polls = self.polls.lock().unwrap();
|
||||||
|
match polls.poll(&index.value()) {
|
||||||
|
Some(&PollFilter::Logs(ref _block_number, ref filter)) => {
|
||||||
|
let logs = take_weak!(self.client).logs(filter.clone())
|
||||||
|
.into_iter()
|
||||||
|
.map(From::from)
|
||||||
|
.collect::<Vec<Log>>();
|
||||||
|
to_value(&logs)
|
||||||
|
},
|
||||||
|
// just empty array
|
||||||
|
_ => Ok(Value::Array(vec![] as Vec<Value>)),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fn uninstall_filter(&self, params: Params) -> Result<Value, Error> {
|
fn uninstall_filter(&self, params: Params) -> Result<Value, Error> {
|
||||||
from_params::<(Index,)>(params)
|
from_params::<(Index,)>(params)
|
||||||
.and_then(|(index,)| {
|
.and_then(|(index,)| {
|
||||||
|
@ -190,6 +190,9 @@ pub trait EthFilter: Sized + Send + Sync + 'static {
|
|||||||
/// Returns filter changes since last poll.
|
/// Returns filter changes since last poll.
|
||||||
fn filter_changes(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
fn filter_changes(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
|
|
||||||
|
/// Returns all logs matching given filter (in a range 'from' - 'to').
|
||||||
|
fn filter_logs(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
|
|
||||||
/// Uninstalls filter.
|
/// Uninstalls filter.
|
||||||
fn uninstall_filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
fn uninstall_filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
|
|
||||||
@ -200,7 +203,7 @@ pub trait EthFilter: Sized + Send + Sync + 'static {
|
|||||||
delegate.add_method("eth_newBlockFilter", EthFilter::new_block_filter);
|
delegate.add_method("eth_newBlockFilter", EthFilter::new_block_filter);
|
||||||
delegate.add_method("eth_newPendingTransactionFilter", EthFilter::new_pending_transaction_filter);
|
delegate.add_method("eth_newPendingTransactionFilter", EthFilter::new_pending_transaction_filter);
|
||||||
delegate.add_method("eth_getFilterChanges", EthFilter::filter_changes);
|
delegate.add_method("eth_getFilterChanges", EthFilter::filter_changes);
|
||||||
delegate.add_method("eth_getFilterLogs", EthFilter::filter_changes);
|
delegate.add_method("eth_getFilterLogs", EthFilter::filter_logs);
|
||||||
delegate.add_method("eth_uninstallFilter", EthFilter::uninstall_filter);
|
delegate.add_method("eth_uninstallFilter", EthFilter::uninstall_filter);
|
||||||
delegate
|
delegate
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user