From 55fdf3e46272ec50a4d55f519b542df790920306 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 20 Mar 2015 12:07:06 +0100 Subject: Listen to tx pre event and trigger 'pending' --- rpc/api.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'rpc/api.go') 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`") } -- cgit v1.2.3