good morning!!!!

Skip to content
Snippets Groups Projects
Commit 6a19b62d authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

added chainSync event

parent a626b7eb
Branches
Tags
No related merge requests found
...@@ -80,6 +80,8 @@ type Ethereum struct { ...@@ -80,6 +80,8 @@ type Ethereum struct {
keyManager *ethcrypto.KeyManager keyManager *ethcrypto.KeyManager
clientIdentity ethwire.ClientIdentity clientIdentity ethwire.ClientIdentity
isUpToDate bool
} }
func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager *ethcrypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) { 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 ...@@ -107,6 +109,7 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager
nat: nat, nat: nat,
keyManager: keyManager, keyManager: keyManager,
clientIdentity: clientIdentity, clientIdentity: clientIdentity,
isUpToDate: true,
} }
ethereum.reactor = ethutil.NewReactorEngine() ethereum.reactor = ethutil.NewReactorEngine()
...@@ -371,6 +374,7 @@ func (s *Ethereum) Start(seed bool) { ...@@ -371,6 +374,7 @@ func (s *Ethereum) Start(seed bool) {
// Start the reaping processes // Start the reaping processes
go s.ReapDeadPeerHandler() go s.ReapDeadPeerHandler()
go s.update()
if seed { if seed {
s.Seed() s.Seed()
...@@ -510,3 +514,23 @@ out: ...@@ -510,3 +514,23 @@ out:
ethlogger.Debugln("succesfully disestablished UPnP port mapping") 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
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment