pass interval to loop as argument

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-06-27 15:50:04 -04:00 committed by Jakub
parent d793156f62
commit 624c286650
2 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import (
"time"
)
func FetchLoop(state *State) {
func FetchLoop(state *State, interval int) {
for {
select {
case <-threadDone:
@ -12,6 +12,6 @@ func FetchLoop(state *State) {
default:
state.Fetch()
}
<-time.After(interval * time.Second)
<-time.After(time.Duration(interval) * time.Second)
}
}

View File

@ -85,8 +85,8 @@ func main() {
g.SetManagerFunc(vm.Layout)
// Start RPC calling routine
go FetchLoop(state)
// Start RPC calling routine for fetching peers periodically.
go FetchLoop(state, interval)
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)