aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-23 22:43:41 +0800
committerobscuren <geffobscura@gmail.com>2015-02-23 22:43:41 +0800
commitb2a225a52e45315f3ec90e11707fefa6059d13f5 (patch)
tree7019227fc4af5e39f88bcc58ddc455826df8d569 /rpc
parent20aa6dde067a0c8d28fdafd43e41f996f014e8b0 (diff)
downloaddexon-b2a225a52e45315f3ec90e11707fefa6059d13f5.tar.gz
dexon-b2a225a52e45315f3ec90e11707fefa6059d13f5.tar.zst
dexon-b2a225a52e45315f3ec90e11707fefa6059d13f5.zip
Properly uninstall filters. Mining issue fixed #closes #365
* Added an additional tx state which is used to get the current nonce * Refresh transient state each time a new canonical block is found * Properly uninstall filters. Fixes a possible crash in RPC
Diffstat (limited to 'rpc')
-rw-r--r--rpc/packages.go11
-rw-r--r--rpc/util.go2
2 files changed, 6 insertions, 7 deletions
diff --git a/rpc/packages.go b/rpc/packages.go
index b51bde7ce..571f3a300 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -126,10 +126,6 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error
self.logMut.Lock()
defer self.logMut.Unlock()
- if self.logs[id] == nil {
- self.logs[id] = &logFilter{timeout: time.Now()}
- }
-
self.logs[id].add(&state.StateLog{})
}
if args == "pending" {
@@ -139,6 +135,7 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error
}
id = self.filterManager.InstallFilter(filter)
+ self.logs[id] = &logFilter{timeout: time.Now()}
*reply = id
return nil
@@ -377,12 +374,10 @@ func (p *EthereumApi) NewWhisperFilter(args *xeth.Options, reply *interface{}) e
args.Fn = func(msg xeth.WhisperMessage) {
p.messagesMut.Lock()
defer p.messagesMut.Unlock()
- if p.messages[id] == nil {
- p.messages[id] = &whisperFilter{timeout: time.Now()}
- }
p.messages[id].add(msg) // = append(p.messages[id], msg)
}
id = p.xeth.Whisper().Watch(args)
+ p.messages[id] = &whisperFilter{timeout: time.Now()}
*reply = id
return nil
}
@@ -623,12 +618,14 @@ done:
self.messagesMut.Lock()
for id, filter := range self.logs {
if time.Since(filter.timeout) > 20*time.Second {
+ self.filterManager.UninstallFilter(id)
delete(self.logs, id)
}
}
for id, filter := range self.messages {
if time.Since(filter.timeout) > 20*time.Second {
+ self.xeth.Whisper().Unwatch(id)
delete(self.messages, id)
}
}
diff --git a/rpc/util.go b/rpc/util.go
index 1939b3474..00a418783 100644
--- a/rpc/util.go
+++ b/rpc/util.go
@@ -108,6 +108,7 @@ func toLogs(logs state.Logs) (ls []Log) {
type whisperFilter struct {
messages []xeth.WhisperMessage
timeout time.Time
+ id int
}
func (w *whisperFilter) add(msgs ...xeth.WhisperMessage) {
@@ -123,6 +124,7 @@ func (w *whisperFilter) get() []xeth.WhisperMessage {
type logFilter struct {
logs state.Logs
timeout time.Time
+ id int
}
func (l *logFilter) add(logs ...state.Log) {