beaconchain

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, log logrus.FieldLogger, monitor string, conf *Config) (*client, error)

NewClient creates a new beaconchain instance

Types

type Client

type Client interface {
	// GetValidators returns a map of validators
	GetValidators(ctx context.Context, pubkeys []string) (map[string]*Validator, error)
	// GetValidator returns a validator
	GetValidator(ctx context.Context, pubkey string) (*Validator, error)
	// GetBatchSize returns the batch size
	GetBatchSize() int
	// GetMaxRequestsPerMinute returns the max requests per minute
	GetMaxRequestsPerMinute() int
	// GetCheckInterval returns the check interval
	GetCheckInterval() time.Duration
}

Client exposes beaconchain client

type Config

type Config struct {
	Enabled              bool          `yaml:"enabled" default:"true"`
	APIKey               string        `yaml:"apiKey"`
	BatchSize            int           `yaml:"batchSize" default:"100"`
	MaxRequestsPerMinute int           `yaml:"maxRequestsPerMinute" default:"10"`
	Endpoint             string        `yaml:"endpoint" default:"https://beaconcha.in"`
	CheckInterval        time.Duration `yaml:"checkInterval" default:"24h"`
}

func (*Config) Validate

func (c *Config) Validate() error

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func GetMetricsInstance

func GetMetricsInstance(namespace, monitorName string) *Metrics

func (Metrics) ObserveRequest

func (m Metrics) ObserveRequest(method, path string)

func (Metrics) ObserveResponse

func (m Metrics) ObserveResponse(method, path, code string, duration time.Duration)

type Response

type Response[T any] struct {
	Data   T      `json:"data"`
	Status string `json:"status"`
}

type Status

type Status string

enum status

const (
	// Transaction is in mempool waiting to be included in a block
	StatusMempool Status = "mempool"

	// Deposit transaction has been included in a block and is waiting for finalization
	StatusDeposited Status = "deposited"

	// Deposit is finalized and validator is in activation queue
	StatusPending Status = "pending"

	// The transaction had an invalid BLS signature
	StatusDepositInvalid Status = "deposit_invalid"

	// Validator is actively participating in consensus
	StatusActiveOnline Status = "active_online"

	// An active validator has not been attesting for at least two epochs
	StatusActiveOffline Status = "active_offline"

	// The validator is online and currently exiting the network because either its balance dropped below 16ETH (forced exit)
	// or the exit was requested (voluntary exit) by the validator
	StatusExitingOnline Status = "exiting_online"

	// The validator is offline and currently exiting the network because either its balance dropped below 16ETH
	// or the exit was requested by the validator
	StatusExitingOffline Status = "exiting_offline"

	// The validator is online but was malicious and therefore forced to exit the network
	StatusSlashingOnline Status = "slashing_online"

	// The validator is offline and was malicious and which lead to a forced to exit out of the network.
	// The validator is currently in the exiting queue with a minimum of 25 minutes
	StatusSlashingOffline Status = "slashing_offline"

	// The validator has been kicked out of the network. The funds will be withdrawable after 36 days
	StatusSlashed Status = "slashed"

	// The validator has exited the network. The funds will be withdrawable after 1 day
	StatusExited Status = "exited"
)

type Validator

type Validator struct {
	ActivationEligibilityEpoch int    `json:"activationeligibilityepoch"`
	ActivationEpoch            int    `json:"activationepoch"`
	Balance                    int    `json:"balance"`
	EffectiveBalance           int    `json:"effectivebalance"`
	ExitEpoch                  int    `json:"exitepoch"`
	LastAttestationSlot        int    `json:"lastattestationslot"`
	Name                       string `json:"name"`
	Pubkey                     string `json:"pubkey"`
	Slashed                    bool   `json:"slashed"`
	Status                     Status `json:"status"`
	ValidatorIndex             int    `json:"validatorindex"`
	WithdrawableEpoch          int    `json:"withdrawableepoch"`
	WithdrawalCredentials      string `json:"withdrawalcredentials"`
	TotalWithdrawals           int    `json:"total_withdrawals"` //nolint:tagliatelle // beaconcha.in response
}

func (*Validator) IsExited

func (v *Validator) IsExited() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL