rpc eth_getFilterChanges returns new blocks, implemented eth_uninstallFilter

This commit is contained in:
debris
2016-02-24 14:16:05 +01:00
parent 932b31227f
commit 0318907fb3
3 changed files with 30 additions and 3 deletions

View File

@@ -267,11 +267,18 @@ impl EthFilter for EthFilterClient {
None => Ok(Value::Array(vec![] as Vec<Value>)),
Some(info) => match info.filter {
PollFilter::Block => {
//unimplemented!()
to_value(&self.client.chain_info().best_block_hash).map(|v| Value::Array(vec![v]))
let current_number = self.client.chain_info().best_block_number;
let hashes = (info.block_number..current_number).into_iter()
.map(BlockId::Number)
.filter_map(|id| self.client.block_hash(id))
.collect::<Vec<H256>>();
self.polls.lock().unwrap().update_poll(&index.value(), current_number);
to_value(&hashes)
},
PollFilter::PendingTransaction => {
//unimplemented!()
// TODO: fix implementation
to_value(&self.client.chain_info().best_block_hash).map(|v| Value::Array(vec![v]))
},
PollFilter::Logs(mut filter) => {
@@ -291,4 +298,12 @@ impl EthFilter for EthFilterClient {
}
})
}
fn uninstall_filter(&self, params: Params) -> Result<Value, Error> {
from_params::<(Index,)>(params)
.and_then(|(index,)| {
self.polls.lock().unwrap().remove_poll(&index.value());
to_value(&true)
})
}
}