add daemon timeout option, stop ytsync gracefully during daemon startup

This commit is contained in:
Alex Grintsvayg 2018-03-08 19:27:54 -05:00
parent 2cd8552702
commit 393e2c4e80

View file

@ -134,7 +134,22 @@ func (s *Sync) FullCycle() error {
} }
log.Infoln("Waiting for daemon to finish starting...") log.Infoln("Waiting for daemon to finish starting...")
s.daemon = jsonrpc.NewClientAndWait("") s.daemon = jsonrpc.NewClient("")
s.daemon.SetRPCTimeout(5 * time.Minute)
WaitForDaemonStart:
for {
select {
case <-s.stop.Chan():
return nil
default:
_, err := s.daemon.WalletBalance()
if err == nil {
break WaitForDaemonStart
}
time.Sleep(5 * time.Second)
}
}
err = s.doSync() err = s.doSync()
if err != nil { if err != nil {