aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-18 04:01:13 +0800
committerobscuren <geffobscura@gmail.com>2014-07-18 04:01:13 +0800
commit6a19b62db6466f88132f5e41868336ff74ef969c (patch)
tree4ed717086f4abeeb17c29eb19b3ab705916b7792 /ethereum.go
parenta626b7ebe1fa5f1029840e25e88a4de426cf64c4 (diff)
downloadgo-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.tar
go-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.tar.gz
go-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.tar.bz2
go-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.tar.lz
go-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.tar.xz
go-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.tar.zst
go-tangerine-6a19b62db6466f88132f5e41868336ff74ef969c.zip
added chainSync event
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/ethereum.go b/ethereum.go
index 2806dfd9d..f43d37be2 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -80,6 +80,8 @@ type Ethereum struct {
keyManager *ethcrypto.KeyManager
clientIdentity ethwire.ClientIdentity
+
+ isUpToDate bool
}
func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager *ethcrypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) {
@@ -107,6 +109,7 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager
nat: nat,
keyManager: keyManager,
clientIdentity: clientIdentity,
+ isUpToDate: true,
}
ethereum.reactor = ethutil.NewReactorEngine()
@@ -371,6 +374,7 @@ func (s *Ethereum) Start(seed bool) {
// Start the reaping processes
go s.ReapDeadPeerHandler()
+ go s.update()
if seed {
s.Seed()
@@ -510,3 +514,23 @@ out:
ethlogger.Debugln("succesfully disestablished UPnP port mapping")
}
}
+
+func (self *Ethereum) update() {
+ upToDateTimer := time.NewTicker(1 * time.Second)
+
+out:
+ for {
+ select {
+ case <-upToDateTimer.C:
+ if self.IsUpToDate() && !self.isUpToDate {
+ self.reactor.Post("chainSync", false)
+ self.isUpToDate = true
+ } else if !self.IsUpToDate() && self.isUpToDate {
+ self.reactor.Post("chainSync", true)
+ self.isUpToDate = false
+ }
+ case <-self.quit:
+ break out
+ }
+ }
+}