From fb76030437d5969e01033336bf02f9ab3cf820cc Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Tue, 26 Sep 2023 16:29:41 +0200 Subject: [PATCH] Added period and start to uptime voting config --- config.toml | 3 ++- indexer/config/config.go | 9 ++++++--- indexer/cronjob/uptime_voting.go | 8 +------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/config.toml b/config.toml index 0151550..3f4338c 100644 --- a/config.toml +++ b/config.toml @@ -50,9 +50,10 @@ enable_voting = false start = "2021-08-01T00:00:00Z" period = "90s" uptime_threshold = 0.8 +delete_old_uptimes_epoch_threshold = 5 [epochs] -# first epoch to be voted for (do not leav this empty since the first epoch is well back in time +# first epoch to be voted for (do not leave this empty since the first epoch is well back in time) first = 1111 [voting_cronjob] diff --git a/indexer/config/config.go b/indexer/config/config.go index f4d25c2..50803ce 100644 --- a/indexer/config/config.go +++ b/indexer/config/config.go @@ -2,6 +2,7 @@ package config import ( "flare-indexer/config" + "flare-indexer/utils" "time" "github.com/ethereum/go-ethereum/common" @@ -50,9 +51,11 @@ type VotingConfig struct { type UptimeConfig struct { CronjobConfig config.EpochConfig - EnableVoting bool `toml:"enable_voting"` - UptimeThreshold float64 `toml:"uptime_threshold"` - DeleteOldUptimesEpochThreshold int64 `toml:"delete_old_uptimes_epoch_threshold"` + Period time.Duration `toml:"period" envconfig:"UPTIME_EPOCH_PERIOD"` + Start utils.Timestamp `toml:"start" envconfig:"UPTIME_EPOCH_START"` + EnableVoting bool `toml:"enable_voting"` + UptimeThreshold float64 `toml:"uptime_threshold"` + DeleteOldUptimesEpochThreshold int64 `toml:"delete_old_uptimes_epoch_threshold"` } type ContractAddresses struct { diff --git a/indexer/cronjob/uptime_voting.go b/indexer/cronjob/uptime_voting.go index 23908ad..cf226d8 100644 --- a/indexer/cronjob/uptime_voting.go +++ b/indexer/cronjob/uptime_voting.go @@ -69,17 +69,11 @@ func NewUptimeVotingCronjob(ctx context.IndexerContext) (*uptimeVotingCronjob, e } config := ctx.Config().UptimeCronjob - - start, period, err := staking.GetEpochConfig(votingContract) - if err != nil { - return nil, err - } - return &uptimeVotingCronjob{ epochCronjob: epochCronjob{ enabled: config.EnableVoting, timeout: config.Timeout, - epochs: staking.NewEpochInfo(&ctx.Config().UptimeCronjob.EpochConfig, start, period), + epochs: staking.NewEpochInfo(&config.EpochConfig, config.Start.Time, config.Period), }, lastAggregatedEpoch: -1, deleteOldUptimesEpochThreshold: config.DeleteOldUptimesEpochThreshold,