aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/rpc/api.go b/rpc/api.go
index afc0bd455..fcf2ac9dc 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -180,21 +180,24 @@ func (self *EthereumApi) NewFilterString(args *FilterStringArgs, reply *interfac
var id int
filter := core.NewFilter(self.xeth().Backend())
- callback := func(block *types.Block, logs state.Logs) {
- self.logMut.Lock()
- defer self.logMut.Unlock()
-
- for _, log := range logs {
- self.logs[id].add(log)
- }
- self.logs[id].add(&state.StateLog{})
- }
-
switch args.Word {
case "pending":
- filter.PendingCallback = callback
+ filter.PendingCallback = func(tx *types.Transaction) {
+ self.logMut.Lock()
+ defer self.logMut.Unlock()
+
+ self.logs[id].add(&state.StateLog{})
+ }
case "latest":
- filter.BlockCallback = callback
+ filter.BlockCallback = func(block *types.Block, logs state.Logs) {
+ self.logMut.Lock()
+ defer self.logMut.Unlock()
+
+ for _, log := range logs {
+ self.logs[id].add(log)
+ }
+ self.logs[id].add(&state.StateLog{})
+ }
default:
return NewValidationError("Word", "Must be `latest` or `pending`")
}