Skip to content

Commit

Permalink
Added period and start to uptime voting config
Browse files Browse the repository at this point in the history
  • Loading branch information
mboben committed Sep 26, 2023
1 parent 0ad098a commit fb76030
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 6 additions & 3 deletions indexer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"flare-indexer/config"
"flare-indexer/utils"
"time"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 1 addition & 7 deletions indexer/cronjob/uptime_voting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fb76030

Please sign in to comment.