added leader-slot-addresses to SlotWatcher

This commit is contained in:
Matt Johnstone 2024-10-04 13:04:23 +02:00
parent 64332b368b
commit db8373b81d
No known key found for this signature in database
GPG Key ID: BE985FBB9BE7D3BB
3 changed files with 10 additions and 4 deletions

View File

@ -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)

View File

@ -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
@ -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)

View File

@ -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()