aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-20 19:07:06 +0800
committerobscuren <geffobscura@gmail.com>2015-03-20 19:07:06 +0800
commit55fdf3e46272ec50a4d55f519b542df790920306 (patch)
tree34f5fdd4551b03a6c69f3639f3f1f715aa6d9b99 /rpc
parentb4a51de6020ce0fdee47eb6c7d63a13647b7e3c4 (diff)
downloaddexon-55fdf3e46272ec50a4d55f519b542df790920306.tar
dexon-55fdf3e46272ec50a4d55f519b542df790920306.tar.gz
dexon-55fdf3e46272ec50a4d55f519b542df790920306.tar.bz2
dexon-55fdf3e46272ec50a4d55f519b542df790920306.tar.lz
dexon-55fdf3e46272ec50a4d55f519b542df790920306.tar.xz
dexon-55fdf3e46272ec50a4d55f519b542df790920306.tar.zst
dexon-55fdf3e46272ec50a4d55f519b542df790920306.zip
Listen to tx pre event and trigger 'pending'
Diffstat (limited to 'rpc')
-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`")
}