added leader-slot-addresses to SlotWatcher
This commit is contained in:
parent
64332b368b
commit
db8373b81d
|
@ -35,8 +35,8 @@ type solanaCollector struct {
|
||||||
rpcClient rpc.Provider
|
rpcClient rpc.Provider
|
||||||
|
|
||||||
// config:
|
// config:
|
||||||
slotPace time.Duration
|
slotPace time.Duration
|
||||||
balanceAddresses []string
|
balanceAddresses []string
|
||||||
leaderSlotAddresses []string
|
leaderSlotAddresses []string
|
||||||
|
|
||||||
/// descriptors:
|
/// descriptors:
|
||||||
|
@ -243,7 +243,7 @@ func main() {
|
||||||
|
|
||||||
collector := NewSolanaCollector(*rpcAddr, balAddresses, lsAddresses)
|
collector := NewSolanaCollector(*rpcAddr, balAddresses, lsAddresses)
|
||||||
|
|
||||||
slotWatcher := SlotWatcher{client: collector.rpcClient}
|
slotWatcher := NewCollectorSlotWatcher(collector)
|
||||||
go slotWatcher.WatchSlots(context.Background(), collector.slotPace)
|
go slotWatcher.WatchSlots(context.Background(), collector.slotPace)
|
||||||
|
|
||||||
prometheus.MustRegister(collector)
|
prometheus.MustRegister(collector)
|
||||||
|
|
|
@ -18,6 +18,8 @@ const (
|
||||||
type SlotWatcher struct {
|
type SlotWatcher struct {
|
||||||
client rpc.Provider
|
client rpc.Provider
|
||||||
|
|
||||||
|
leaderSlotAddresses []string
|
||||||
|
|
||||||
// currentEpoch is the current epoch we are watching
|
// currentEpoch is the current epoch we are watching
|
||||||
currentEpoch int64
|
currentEpoch int64
|
||||||
// firstSlot is the first slot [inclusive] of the current epoch which we are watching
|
// 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() {
|
func init() {
|
||||||
prometheus.MustRegister(totalTransactionsTotal)
|
prometheus.MustRegister(totalTransactionsTotal)
|
||||||
prometheus.MustRegister(confirmedSlotHeight)
|
prometheus.MustRegister(confirmedSlotHeight)
|
||||||
|
|
|
@ -92,7 +92,7 @@ func TestSolanaCollector_WatchSlots_Static(t *testing.T) {
|
||||||
leaderSlotsByEpoch.Reset()
|
leaderSlotsByEpoch.Reset()
|
||||||
|
|
||||||
collector := createSolanaCollector(&staticRPCClient{}, 100*time.Millisecond, identities, []string{})
|
collector := createSolanaCollector(&staticRPCClient{}, 100*time.Millisecond, identities, []string{})
|
||||||
watcher := SlotWatcher{client: collector.rpcClient}
|
watcher := NewCollectorSlotWatcher(collector)
|
||||||
prometheus.NewPedanticRegistry().MustRegister(collector)
|
prometheus.NewPedanticRegistry().MustRegister(collector)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
Loading…
Reference in New Issue