From 2e3a6e2559d02ba90957eaf333e571dec935e00a Mon Sep 17 00:00:00 2001
From: Taylor Gerring <taylor.gerring@gmail.com>
Date: Tue, 24 Feb 2015 19:54:18 +0100
Subject: [PATCH] Consolidate related items

---
 rpc/api.go | 73 +++++++++++++++++++++++++++---------------------------
 1 file 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)
-}
-- 
GitLab