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

chore: run golines #97

Merged
merged 1 commit into from
Oct 26, 2023
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
14 changes: 11 additions & 3 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func getNodeMetrics(ctx context.Context) ([]byte, int, error) {
return respBodyBytes, http.StatusInternalServerError, err
}
// Set a 3 second timeout
ctx, cancel := context.WithTimeout(ctx, time.Second*time.Duration(cfg.Prometheus.Timeout))
ctx, cancel := context.WithTimeout(
ctx,
time.Second*time.Duration(cfg.Prometheus.Timeout),
)
defer cancel()
req = req.WithContext(ctx)
// Get metrics from the node
Expand Down Expand Up @@ -86,7 +89,9 @@ func getEpoch() uint64 {
func getSlotTipRef(g *localstatequery.GenesisConfigResult) uint64 {
cfg := config.GetConfig()
currentTimeSec := uint64(time.Now().Unix() - 1)
byronSlots := uint64(cfg.Node.ShelleyTransEpoch) * cfg.Node.ByronGenesis.EpochLength
byronSlots := uint64(
cfg.Node.ShelleyTransEpoch,
) * cfg.Node.ByronGenesis.EpochLength
byronEndTime := cfg.Node.ByronGenesis.StartTime + ((uint64(cfg.Node.ShelleyTransEpoch) * cfg.Node.ByronGenesis.EpochLength * cfg.Node.ByronGenesis.SlotLength) / 1000)
if currentTimeSec < byronEndTime {
return ((currentTimeSec - cfg.Node.ByronGenesis.StartTime) * 1000) / cfg.Node.ByronGenesis.SlotLength
Expand All @@ -95,7 +100,10 @@ func getSlotTipRef(g *localstatequery.GenesisConfigResult) uint64 {
}

// Calculate KES expiration from node metrics
func kesExpiration(g *localstatequery.GenesisConfigResult, p *PromMetrics) time.Time {
func kesExpiration(
g *localstatequery.GenesisConfigResult,
p *PromMetrics,
) time.Time {
currentTimeSec := uint64(time.Now().Unix() - 1)
expirationTimeSec := currentTimeSec - (uint64(g.SlotLength/1000000) * (getSlotTipRef(g) % uint64(g.SlotsPerKESPeriod))) + (uint64(g.SlotLength/1000000) + uint64(g.SlotsPerKESPeriod)*p.RemainingKesPeriods)
return time.Unix(int64(expirationTimeSec), 0)
Expand Down
Loading
Loading