浏览代码

eth/filters: fix the block range assignment for log filter (#17284)

gary rong 7 年之前
父节点
当前提交
c4a1d4fecf
共有 1 个文件被更改,包括 6 次插入8 次删除
  1. 6 8
      eth/filters/api.go

+ 6 - 8
eth/filters/api.go

@@ -330,15 +330,13 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([
 		filter = NewBlockFilter(api.backend, *crit.BlockHash, crit.Addresses, crit.Topics)
 	} else {
 		// Convert the RPC block numbers into internal representations
-		var (
-			begin int64
-			end   int64
-		)
-		if crit.FromBlock == nil {
-			begin = int64(rpc.LatestBlockNumber)
+		begin := rpc.LatestBlockNumber.Int64()
+		if crit.FromBlock != nil {
+			begin = crit.FromBlock.Int64()
 		}
-		if crit.ToBlock == nil {
-			end = int64(rpc.LatestBlockNumber)
+		end := rpc.LatestBlockNumber.Int64()
+		if crit.ToBlock != nil {
+			end = crit.ToBlock.Int64()
 		}
 		// Construct the range filter
 		filter = NewRangeFilter(api.backend, begin, end, crit.Addresses, crit.Topics)