Skip to content

Commit

Permalink
fix: only count pythnet messages in guardian observation counter
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Nov 29, 2023
1 parent 05cab59 commit 7ba5247
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"context"
"encoding/hex"
"strconv"
"strings"
"time"

"github.com/certusone/wormhole/node/pkg/common"
Expand Down Expand Up @@ -63,8 +65,19 @@ func ReceiveMessages(channel chan *vaa.VAA, heartbeat *Heartbeat, networkID, boo
case <-rootCtx.Done():
return
case o := <-obsvC:
guardian := hex.EncodeToString(o.Msg.Addr)
observationsMetric.WithLabelValues(guardian).Inc()
// A messageId has `chain/emittter/seq` format. We are only interested in the chainId.
// ChainId is a uint16 represented in base 10.
chainId, err := strconv.ParseUint(strings.Split(o.Msg.MessageId, "/")[0], 10, 16)

if err != nil {
log.Error().Err(err).Msg("Failed to parse chainId")
continue
}

if vaa.ChainID(chainId) == vaa.ChainIDPythNet {
guardian := hex.EncodeToString(o.Msg.Addr)
observationsMetric.WithLabelValues(guardian).Inc()
}
}
}
}()
Expand Down

0 comments on commit 7ba5247

Please sign in to comment.