Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
corverroos committed Apr 24, 2023
1 parent 7393ae4 commit 06af57b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
28 changes: 0 additions & 28 deletions app/eth2wrap/httpwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 29 additions & 0 deletions app/eth2wrap/valcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 06af57b

Please sign in to comment.