Missing blocks in filter_changes RPC (#9947)
* feat + fix: Missing blocks in filter_changes RPC * Implement validity check of reported hashes (in case of re-org) and re-set last_block to the last block reported that is still valid. * Add const to set history size for validity check (32). * test: in the case of a re-org we get same block number if hash is different
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
//! Helper type with all filter state data.
|
||||
|
||||
use std::{
|
||||
collections::{BTreeSet, HashSet},
|
||||
collections::{BTreeSet, HashSet, VecDeque},
|
||||
sync::Arc,
|
||||
};
|
||||
use ethereum_types::H256;
|
||||
@@ -49,7 +49,11 @@ impl SyncPollFilter {
|
||||
#[derive(Clone)]
|
||||
pub enum PollFilter {
|
||||
/// Number of last block which client was notified about.
|
||||
Block(BlockNumber),
|
||||
Block {
|
||||
last_block_number: BlockNumber,
|
||||
#[doc(hidden)]
|
||||
recent_reported_hashes: VecDeque<(BlockNumber, H256)>,
|
||||
},
|
||||
/// Hashes of all pending transactions the client knows about.
|
||||
PendingTransaction(BTreeSet<H256>),
|
||||
/// Number of From block number, last seen block hash, pending logs and log filter itself.
|
||||
@@ -62,6 +66,10 @@ pub enum PollFilter {
|
||||
}
|
||||
}
|
||||
|
||||
impl PollFilter {
|
||||
pub (in v1) const MAX_BLOCK_HISTORY_SIZE: usize = 32;
|
||||
}
|
||||
|
||||
/// Returns only last `n` logs
|
||||
pub fn limit_logs(mut logs: Vec<Log>, limit: Option<usize>) -> Vec<Log> {
|
||||
let len = logs.len();
|
||||
|
||||
Reference in New Issue
Block a user