aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-02-25 02:54:18 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-02-25 02:54:18 +0800
commit2e3a6e2559d02ba90957eaf333e571dec935e00a (patch)
treedbc70554c56fe2f23d95df946c87209a5d08b94a /rpc/api.go
parentc8e9abff53d869f74211e157abcb2827d181e106 (diff)
downloaddexon-2e3a6e2559d02ba90957eaf333e571dec935e00a.tar.gz
dexon-2e3a6e2559d02ba90957eaf333e571dec935e00a.tar.zst
dexon-2e3a6e2559d02ba90957eaf333e571dec935e00a.zip
Consolidate related items
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go73
1 files changed, 36 insertions, 37 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 813fef949..21c85bbcc 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -25,8 +25,9 @@ import (
)
var (
- defaultGasPrice = big.NewInt(10000000000000)
- defaultGas = big.NewInt(10000)
+ defaultGasPrice = big.NewInt(10000000000000)
+ defaultGas = big.NewInt(10000)
+ filterTickerTime = 15 * time.Second
)
type EthereumApi struct {
@@ -62,6 +63,39 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
return api
}
+func (self *EthereumApi) start() {
+ timer := time.NewTicker(filterTickerTime)
+done:
+ for {
+ select {
+ case <-timer.C:
+ self.logMut.Lock()
+ 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)
+ }
+ }
+ self.logMut.Unlock()
+ self.messagesMut.Unlock()
+ case <-self.quit:
+ break done
+ }
+ }
+}
+
+func (self *EthereumApi) stop() {
+ close(self.quit)
+}
+
func (self *EthereumApi) Register(args string, reply *interface{}) error {
self.regmut.Lock()
defer self.regmut.Unlock()
@@ -600,38 +634,3 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
rpclogger.DebugDetailf("Reply: %T %s", reply, reply)
return nil
}
-
-var filterTickerTime = 15 * time.Second
-
-func (self *EthereumApi) start() {
- timer := time.NewTicker(filterTickerTime)
-done:
- for {
- select {
- case <-timer.C:
- self.logMut.Lock()
- 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)
- }
- }
- self.logMut.Unlock()
- self.messagesMut.Unlock()
- case <-self.quit:
- break done
- }
- }
-}
-
-func (self *EthereumApi) stop() {
- close(self.quit)
-}