aboutsummaryrefslogtreecommitdiffstats
path: root/eth/filters
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-08-31 23:09:50 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-10-04 07:13:56 +0800
commit7c7692933c21b77328a94eed714f66c276776197 (patch)
treef7a394c1823dd4da1ed2b37709c1c8f52c51b6ef /eth/filters
parent361082ec4b942aea7c01fcb1be1782cb68b6fe3a (diff)
downloaddexon-7c7692933c21b77328a94eed714f66c276776197.tar
dexon-7c7692933c21b77328a94eed714f66c276776197.tar.gz
dexon-7c7692933c21b77328a94eed714f66c276776197.tar.bz2
dexon-7c7692933c21b77328a94eed714f66c276776197.tar.lz
dexon-7c7692933c21b77328a94eed714f66c276776197.tar.xz
dexon-7c7692933c21b77328a94eed714f66c276776197.tar.zst
dexon-7c7692933c21b77328a94eed714f66c276776197.zip
cmd/geth, cmd/utils, core, rpc: renamed to blockchain
* Renamed ChainManager to BlockChain * Checkpointing is no longer required and never really properly worked when the state was corrupted.
Diffstat (limited to 'eth/filters')
-rw-r--r--eth/filters/filter.go17
-rw-r--r--eth/filters/filter_system.go2
2 files changed, 12 insertions, 7 deletions
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index 0b4911629..2bcf20d0c 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -1,4 +1,4 @@
-// Copyright 2014 The go-ethereum Authors
+// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
@@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
+ "github.com/ethereum/go-ethereum/ethdb"
)
type AccountChange struct {
@@ -31,7 +32,7 @@ type AccountChange struct {
// Filtering interface
type Filter struct {
- db common.Database
+ db ethdb.Database
earliest int64
latest int64
skip int
@@ -46,7 +47,7 @@ type Filter struct {
// Create a new filter which uses a bloom filter on blocks to figure out whether a particular block
// is interesting or not.
-func New(db common.Database) *Filter {
+func New(db ethdb.Database) *Filter {
return &Filter{db: db}
}
@@ -79,7 +80,7 @@ func (self *Filter) SetSkip(skip int) {
// Run filters logs with the current parameters set
func (self *Filter) Find() vm.Logs {
- earliestBlock := core.GetCurrentBlock(self.db)
+ earliestBlock := core.GetBlock(self.db, core.GetHeadBlockHash(self.db))
var earliestBlockNo uint64 = uint64(self.earliest)
if self.earliest == -1 {
earliestBlockNo = earliestBlock.NumberU64()
@@ -91,8 +92,12 @@ func (self *Filter) Find() vm.Logs {
var (
logs vm.Logs
- block = core.GetBlockByNumber(self.db, latestBlockNo)
+ block *types.Block
)
+ hash := core.GetCanonicalHash(self.db, latestBlockNo)
+ if hash != (common.Hash{}) {
+ block = core.GetBlock(self.db, hash)
+ }
done:
for i := 0; block != nil; i++ {
@@ -120,7 +125,7 @@ done:
logs = append(logs, self.FilterLogs(unfiltered)...)
}
- block = core.GetBlockByHash(self.db, block.ParentHash())
+ block = core.GetBlock(self.db, block.ParentHash())
}
skip := int(math.Min(float64(len(logs)), float64(self.skip)))
diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go
index 1c27c7be4..4972dcd59 100644
--- a/eth/filters/filter_system.go
+++ b/eth/filters/filter_system.go
@@ -28,7 +28,7 @@ import (
// FilterSystem manages filters that filter specific events such as
// block, transaction and log events. The Filtering system can be used to listen
-// for specific LOG events fires by the EVM (Ethereum Virtual Machine).
+// for specific LOG events fired by the EVM (Ethereum Virtual Machine).
type FilterSystem struct {
eventMux *event.TypeMux