Start sync loops only if -sync=true

This commit is contained in:
Martin Boehm 2018-02-02 16:17:33 +01:00
parent cf15f0cf0c
commit ac5aa2a234

View File

@ -116,12 +116,11 @@ func main() {
if err := resyncIndex(); err != nil { if err := resyncIndex(); err != nil {
glog.Fatal("resyncIndex ", err) glog.Fatal("resyncIndex ", err)
} }
go syncIndexLoop()
go syncMempoolLoop()
chanSyncMempool <- struct{}{}
} }
go syncIndexLoop()
go syncMempoolLoop()
chanSyncMempool <- struct{}{}
var httpServer *server.HTTPServer var httpServer *server.HTTPServer
if *httpServerBinding != "" { if *httpServerBinding != "" {
httpServer, err = server.NewHTTPServer(*httpServerBinding, index, mempool) httpServer, err = server.NewHTTPServer(*httpServerBinding, index, mempool)
@ -184,10 +183,12 @@ func main() {
waitForSignalAndShutdown(httpServer, mq, 5*time.Second) waitForSignalAndShutdown(httpServer, mq, 5*time.Second)
} }
close(chanSyncIndex) if *synchronize {
close(chanSyncMempool) close(chanSyncIndex)
<-chanSyncIndexDone close(chanSyncMempool)
<-chanSyncMempoolDone <-chanSyncIndexDone
<-chanSyncMempoolDone
}
} }
func tickAndDebounce(tickTime time.Duration, debounceTime time.Duration, input chan struct{}, f func()) { func tickAndDebounce(tickTime time.Duration, debounceTime time.Duration, input chan struct{}, f func()) {