File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -546,6 +546,13 @@ where
546546 . transpose ( ) ?
547547 . flatten ( ) ;
548548
549+ // Return error if toBlock exceeds current head
550+ if let Some ( t) = to &&
551+ t > info. best_number
552+ {
553+ return Err ( EthFilterError :: BlockRangeExceedsHead ) ;
554+ }
555+
549556 if let Some ( f) = from &&
550557 f > info. best_number
551558 {
@@ -894,6 +901,9 @@ pub enum EthFilterError {
894901 /// Invalid block range.
895902 #[ error( "invalid block range params" ) ]
896903 InvalidBlockRangeParams ,
904+ /// Block range extends beyond current head.
905+ #[ error( "block range extends beyond current head block" ) ]
906+ BlockRangeExceedsHead ,
897907 /// Query scope is too broad.
898908 #[ error( "query exceeds max block range {0}" ) ]
899909 QueryExceedsMaxBlocks ( u64 ) ,
@@ -928,7 +938,8 @@ impl From<EthFilterError> for jsonrpsee::types::error::ErrorObject<'static> {
928938 EthFilterError :: EthAPIError ( err) => err. into ( ) ,
929939 err @ ( EthFilterError :: InvalidBlockRangeParams |
930940 EthFilterError :: QueryExceedsMaxBlocks ( _) |
931- EthFilterError :: QueryExceedsMaxResults { .. } ) => {
941+ EthFilterError :: QueryExceedsMaxResults { .. } |
942+ EthFilterError :: BlockRangeExceedsHead ) => {
932943 rpc_error_with_code ( jsonrpsee:: types:: error:: INVALID_PARAMS_CODE , err. to_string ( ) )
933944 }
934945 }
You can’t perform that action at this time.
0 commit comments