eth_getLogs implementation
This commit is contained in:
parent
bae2682518
commit
fada9bb1ba
@ -15,6 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Eth rpc implementation.
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
use ethsync::{EthSync, SyncState};
|
||||
use jsonrpc_core::*;
|
||||
@ -25,7 +26,7 @@ use ethcore::client::*;
|
||||
use ethcore::views::*;
|
||||
use ethcore::ethereum::denominations::shannon;
|
||||
use v1::traits::{Eth, EthFilter};
|
||||
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, OptionalValue, Index};
|
||||
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, OptionalValue, Index, Filter};
|
||||
|
||||
/// Eth rpc implementation.
|
||||
pub struct EthClient {
|
||||
@ -197,6 +198,21 @@ impl Eth for EthClient {
|
||||
from_params::<(BlockNumber, Index)>(params)
|
||||
.and_then(|(number, index)| self.transaction(TransactionId::Location(number.into(), index.value())))
|
||||
}
|
||||
|
||||
fn logs(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(Filter,)>(params)
|
||||
.and_then(|(filter,)| {
|
||||
let possibilities = filter.bloom_possibilities();
|
||||
let from = filter.from_block.map_or_else(|| BlockId::Earliest, Into::into);
|
||||
let to = filter.to_block.map_or_else(|| BlockId::Latest, Into::into);
|
||||
let blocks: HashSet<u64> = possibilities.iter()
|
||||
.map(|bloom| self.client.blocks_with_bloom(bloom, from.clone(), to.clone()))
|
||||
.filter_map(|m| m)
|
||||
.flat_map(|m| m)
|
||||
.collect();
|
||||
to_value(&blocks)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user