Skip to content

Commit

Permalink
added leader-slot-addresses to SlotWatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonematt committed Oct 4, 2024
1 parent 64332b3 commit db8373b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmd/solana_exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type solanaCollector struct {
rpcClient rpc.Provider

// config:
slotPace time.Duration
balanceAddresses []string
slotPace time.Duration
balanceAddresses []string
leaderSlotAddresses []string

/// descriptors:
Expand Down Expand Up @@ -243,7 +243,7 @@ func main() {

collector := NewSolanaCollector(*rpcAddr, balAddresses, lsAddresses)

slotWatcher := SlotWatcher{client: collector.rpcClient}
slotWatcher := NewCollectorSlotWatcher(collector)
go slotWatcher.WatchSlots(context.Background(), collector.slotPace)

prometheus.MustRegister(collector)
Expand Down
6 changes: 6 additions & 0 deletions cmd/solana_exporter/slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const (
type SlotWatcher struct {
client rpc.Provider

leaderSlotAddresses []string

// currentEpoch is the current epoch we are watching
currentEpoch int64
// firstSlot is the first slot [inclusive] of the current epoch which we are watching
Expand Down Expand Up @@ -71,6 +73,10 @@ var (
)
)

func NewCollectorSlotWatcher(collector *solanaCollector) *SlotWatcher {
return &SlotWatcher{client: collector.rpcClient, leaderSlotAddresses: collector.leaderSlotAddresses}
}

func init() {
prometheus.MustRegister(totalTransactionsTotal)
prometheus.MustRegister(confirmedSlotHeight)
Expand Down
2 changes: 1 addition & 1 deletion cmd/solana_exporter/slots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestSolanaCollector_WatchSlots_Static(t *testing.T) {
leaderSlotsByEpoch.Reset()

collector := createSolanaCollector(&staticRPCClient{}, 100*time.Millisecond, identities, []string{})
watcher := SlotWatcher{client: collector.rpcClient}
watcher := NewCollectorSlotWatcher(collector)
prometheus.NewPedanticRegistry().MustRegister(collector)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down

0 comments on commit db8373b

Please sign in to comment.