From 06af57bf486d2a379dbf30c1bbb841520d4f0a41 Mon Sep 17 00:00:00 2001 From: corverroos Date: Mon, 24 Apr 2023 11:07:52 +0200 Subject: [PATCH] cleanup --- app/eth2wrap/httpwrap.go | 28 ---------------------------- app/eth2wrap/valcache.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/app/eth2wrap/httpwrap.go b/app/eth2wrap/httpwrap.go index d1351fbb5..65c4fe43e 100644 --- a/app/eth2wrap/httpwrap.go +++ b/app/eth2wrap/httpwrap.go @@ -37,34 +37,6 @@ type NodePeerCountProvider interface { NodePeerCount(ctx context.Context) (int, error) } -type ActiveValidators map[eth2p0.ValidatorIndex]eth2p0.BLSPubKey - -// Pubkeys returns a list of active validator pubkeys. -func (m ActiveValidators) Pubkeys() []eth2p0.BLSPubKey { - var pubkeys []eth2p0.BLSPubKey - for _, pubkey := range m { - pubkeys = append(pubkeys, pubkey) - } - - return pubkeys -} - -// Indices returns a list of active validator indices. -func (m ActiveValidators) Indices() []eth2p0.ValidatorIndex { - var indices []eth2p0.ValidatorIndex - for index := range m { - indices = append(indices, index) - } - - return indices -} - -// ActiveValidatorsProvider is the interface for providing current epoch's cached active validator -// identity information. -type ActiveValidatorsProvider interface { - ActiveValidators(context.Context) (ActiveValidators, error) -} - // NewHTTPAdapterForT returns a http adapter for testing non-eth2service methods as it is nil. func NewHTTPAdapterForT(_ *testing.T, address string, timeout time.Duration) Client { return newHTTPAdapter(nil, address, timeout) diff --git a/app/eth2wrap/valcache.go b/app/eth2wrap/valcache.go index 2f91ae703..9e1f2f535 100644 --- a/app/eth2wrap/valcache.go +++ b/app/eth2wrap/valcache.go @@ -11,6 +11,35 @@ import ( "github.com/obolnetwork/charon/app/errors" ) +// ActiveValidators is a map of active validator indices to pubkeys. +type ActiveValidators map[eth2p0.ValidatorIndex]eth2p0.BLSPubKey + +// Pubkeys returns a list of active validator pubkeys. +func (m ActiveValidators) Pubkeys() []eth2p0.BLSPubKey { + var pubkeys []eth2p0.BLSPubKey + for _, pubkey := range m { + pubkeys = append(pubkeys, pubkey) + } + + return pubkeys +} + +// Indices returns a list of active validator indices. +func (m ActiveValidators) Indices() []eth2p0.ValidatorIndex { + var indices []eth2p0.ValidatorIndex + for index := range m { + indices = append(indices, index) + } + + return indices +} + +// ActiveValidatorsProvider is the interface for providing current epoch's cached active validator +// identity information. +type ActiveValidatorsProvider interface { + ActiveValidators(context.Context) (ActiveValidators, error) +} + // NewValidatorCache creates a new validator cache. func NewValidatorCache(eth2Cl Client, pubkeys []eth2p0.BLSPubKey) *ValidatorCache { return &ValidatorCache{