From ab9c2e1b2ea7daed1fa51b022c6605b2c7249aa8 Mon Sep 17 00:00:00 2001 From: mbidenaio <50830972+mbidenaio@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:36:35 +0500 Subject: [PATCH] Make all flips loading time configurable (#773) --- config/config.go | 5 +++-- config/sync.go | 9 ++++++--- core/ceremony/ceremony.go | 3 +-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index f60a7ee7..bd533293 100644 --- a/config/config.go +++ b/config/config.go @@ -251,8 +251,9 @@ func getDefaultConfig(dataDir string) *Config { IpfsConf: ipfsConfig, Validation: &ValidationConfig{}, Sync: &SyncConfig{ - FastSync: true, - ForceFullSync: DefaultForceFullSync, + FastSync: true, + ForceFullSync: DefaultForceFullSync, + AllFlipsLoadingTime: time.Hour * 2, }, OfflineDetection: GetDefaultOfflineDetectionConfig(), Blockchain: &BlockchainConfig{ diff --git a/config/sync.go b/config/sync.go index 26a119b6..68517ae2 100644 --- a/config/sync.go +++ b/config/sync.go @@ -1,7 +1,10 @@ package config +import "time" + type SyncConfig struct { - FastSync bool - ForceFullSync uint64 - LoadAllFlips bool + FastSync bool + ForceFullSync uint64 + LoadAllFlips bool + AllFlipsLoadingTime time.Duration } diff --git a/core/ceremony/ceremony.go b/core/ceremony/ceremony.go index dcbffc2c..2c2e3607 100644 --- a/core/ceremony/ceremony.go +++ b/core/ceremony/ceremony.go @@ -43,7 +43,6 @@ const ( MaxShortAnswersBroadcastDelaySec = 30 // Flip keys will stop syncing with peers in FlipKeysSyncTimeFrame seconds after short session start FlipKeysSyncTimeFrame = 60 * 4 // seconds - AllFlipsLoadingTime = time.Hour * 2 ) type ValidationCeremony struct { @@ -312,7 +311,7 @@ func (vc *ValidationCeremony) startValidationShortSessionTimer() { select { case <-ticker.C: // load all flips in case of public node - if vc.config.Sync.LoadAllFlips && !vc.allFlipsIsLoading && time.Now().UTC().Add(AllFlipsLoadingTime).After(validationTime) { + if vc.config.Sync.LoadAllFlips && !vc.allFlipsIsLoading && time.Now().UTC().Add(vc.config.Sync.AllFlipsLoadingTime).After(validationTime) { vc.allFlipsIsLoading = true go vc.loadAllFlips(ctx) }