-
Notifications
You must be signed in to change notification settings - Fork 21.5k
Description
System information
Geth
Version: 1.6.7-stable
Git Commit: ab5646c
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.8.1
Operating System: linux
Expected behaviour
Setting up a simple log filter for a given contract address starting at block 1000000:
client, _ := ethclient.Dial("/home/foo/.ethereum/geth.ipc")
filter := ethereum.FilterQuery{}
filter.Addresses = make([]common.Address, 0)
filter.Addresses = append(filter.Addresses, common.HexToAddress("0x..."))
filter.FromBlock = big.NewInt(1000000)
Using this with filterLogs() provides a set of results:
logs, _ := client.FilterLogs(ctx, filter)
fmt.Println(len(logs)) // Ouptuts '143'
However using SubscribeFilterLogs() does not provide any immediate results:
ctx := context.Background()
ch := make(chan types.Log)
client.SubscribeFilterLogs(ctx, filter, ch)
for true {
log := <-ch
fmt.Println("Matching log encountered")
}
It is expected that SubscribeFilterLogs() start from the block as specified in the FilterQuery's FromBlock.
Actual behaviour
SubscribeFilterLogs() appears to start from the first new block received by the client regardless of the block as specified in the FilterQuery's FromBlock.
Steps to reproduce the behaviour
The above code provides the scenario to test (pick your favourite contract address and start block for testing purposes).