Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all flips loading time configurable #773

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
9 changes: 6 additions & 3 deletions config/sync.go
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 1 addition & 2 deletions core/ceremony/ceremony.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down