Use eth_getLogs to work with load-balancing.

This doesn't register a new filter on the server and fixes use with
load-balanced servers like https://core.poa.network.

Fixes #4, fixes #9, fixes #10.
This commit is contained in:
Andreas Fackler 2018-05-21 12:06:15 +02:00
parent b5aaf0b722
commit fc967e46e3
2 changed files with 5 additions and 9 deletions

View File

@ -16,10 +16,6 @@ The `-c` option takes a map with the POA contracts' addresses in JSON format. Yo
current maps for the main and test network the `contracts` folder. By default, it uses `core.json`,
for the main network.
**It doesn't work with https://core.poa.network at the moment!**
Please use https://core-solo.poa.network instead.
See [issue #4](https://github.com/poanetwork/poa-ballot-stats/issues/4) for details.
Examples:
```bash

View File

@ -3,6 +3,7 @@ use std::str::FromStr;
use std::{fmt, u8};
use web3;
use web3::futures::Future;
use web3::helpers::CallResult;
// TODO: Evaluate whether any of these would make sense to include in `web3`.
@ -113,11 +114,10 @@ impl TopicFilterExt for ethabi::TopicFilter {
self,
web3: &web3::Web3<T>,
) -> Result<Vec<web3::types::Log>, web3::error::Error> {
web3.eth_filter()
.create_logs_filter(self.to_filter_builder().build())
.wait()?
.logs()
.wait()
// TODO: Once a version with https://github.com/tomusdrw/rust-web3/pull/122 is available:
// self.transport.logs(self.to_filter_builder().build())
let filter = web3::helpers::serialize(&self.to_filter_builder().build());
CallResult::new(web3.transport().execute("eth_getLogs", vec![filter])).wait()
}
}