Skip to content

Commit

Permalink
Make all flips loading time configurable (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbidenaio authored Aug 17, 2021
1 parent 77e6f54 commit ab9c2e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
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

0 comments on commit ab9c2e1

Please sign in to comment.