Skip to content

Commit

Permalink
fly/cmd: review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
panoel authored and evan-gray committed Sep 19, 2023
1 parent 8a2995f commit 7fce0fc
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions fly/cmd/heartbeats/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ var guardianIndexToNameMap = map[int]string{
var lastTime = time.Now()

const numGuardians = 19
const totalsRow = numGuardians

func main() {

Expand Down Expand Up @@ -212,35 +213,14 @@ func main() {
// First dimension = guardian id
// Second dimension = gossip message type
// Value = count
const totalsRow = numGuardians
if len(gs.Keys) != numGuardians {
logger.Error("Invalid number of guardians.", zap.Int("found", len(gs.Keys)), zap.Uint32("expected", numGuardians))
return
}

var gossipLock sync.Mutex
// The extra row is for the totals
var gossipCounter = [numGuardians + 1][GSM_maxTypeVal]int{
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}
var gossipCounter [numGuardians + 1][GSM_maxTypeVal]int

activeTable := 1 // 0 = chains, 1 = guardians, 2 = message counts, 3 = obsv rate

Expand Down Expand Up @@ -587,7 +567,7 @@ func handleObsv(idx uint) bool {
}
for i := 0; i < numGuardians; i++ {
obsvRateRows[i].obsvCount = currentObsvTable[uint(i)]
pct := currentObsvTable[uint(i)] * 100 / currentObsvTable[numGuardians]
pct := currentObsvTable[uint(i)] * 100 / currentObsvTable[totalsRow]
for j := 0; j < 10; j++ {
if pct >= uint(j+1) {
obsvRateRows[i].percents[j] = "="
Expand All @@ -600,7 +580,7 @@ func handleObsv(idx uint) bool {
needToRender = true
}
currentObsvData[idx]++
currentObsvData[numGuardians]++
currentObsvData[totalsRow]++
return needToRender
}

Expand Down

0 comments on commit 7fce0fc

Please sign in to comment.