Skip to content

Commit

Permalink
fix: remove report command
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Jan 9, 2024
1 parent 5fabc16 commit 2cad7bc
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions discord/discord.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package discord

import (
"encoding/json"
"fmt"
"log"
"os"
"strings"
"time"

Expand Down Expand Up @@ -260,61 +258,6 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}

if m.Content == "pip19-report" {
t := time.Now()

total := float64(0)
scoresSum := float64(0)

results := []Result{}

info, err := b.cm.GetNetworkInfo()
if err != nil {
msg := "error getting network info"
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}

for _, p := range info.ConnectedPeers {
fmt.Println("new peer")
r := Result{}
r.Agent = p.Agent
r.RemoteAddress = p.Address
r.IsActive = true
if p.Height < 673_000 {
r.IsActive = false
}
for _, v := range p.ConsensusKeys {
fmt.Println("new validator")
val, err := b.cm.GetValidatorInfo(v)
if err != nil {
continue
}
r.PIP19Score = val.Validator.AvailabilityScore
r.ValidatorAddress = v

results = append(results, r)
}
}

data, err := json.Marshal(results)
if err != nil {
msg := "error saving report"
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}

if err = os.WriteFile("pip19Report.json", data, 0o600); err != nil {
msg := "error saving report"
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}

msg := fmt.Sprintf("time:%v\n avg:%.10f", t.Unix(), scoresSum/total)
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}
}

// help sends a message detailing how to use the bot discord-client side
Expand Down

0 comments on commit 2cad7bc

Please sign in to comment.