storage

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

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

Collection struct

func (*Collection) CleanRegistryData added in v0.1.11

func (s *Collection) CleanRegistryData() error

CleanRegistryData clears all registry data

func (*Collection) GetAllValidatorShares added in v0.1.11

func (s *Collection) GetAllValidatorShares() ([]*Share, error)

GetAllValidatorShares returns all shares

func (*Collection) GetOperatorValidatorShares added in v0.1.11

func (s *Collection) GetOperatorValidatorShares(operatorPubKey string) ([]*Share, error)

GetOperatorValidatorShares returns all validator shares belongs to operator

func (*Collection) GetValidatorShare added in v0.0.18

func (s *Collection) GetValidatorShare(key []byte) (*Share, bool, error)

GetValidatorShare by key

func (*Collection) SaveValidatorShare

func (s *Collection) SaveValidatorShare(share *Share) error

SaveValidatorShare save validator share to db

func (*Collection) UpdateValidatorMetadata added in v0.1.5

func (s *Collection) UpdateValidatorMetadata(pk string, metadata *beacon.ValidatorMetadata) error

UpdateValidatorMetadata updates the metadata of the given validator

type CollectionOptions

type CollectionOptions struct {
	DB     basedb.IDb
	Logger *zap.Logger
}

CollectionOptions struct

type ICollection

type ICollection interface {
	basedb.RegistryStore

	SaveValidatorShare(share *Share) error
	GetValidatorShare(key []byte) (*Share, bool, error)
	GetAllValidatorShares() ([]*Share, error)
	GetOperatorValidatorShares(operatorPubKey string) ([]*Share, error)
}

ICollection interface for validator storage

func NewCollection

func NewCollection(options CollectionOptions) ICollection

NewCollection creates new share storage

type PubKeys

type PubKeys []*bls.PublicKey

PubKeys defines the type for public keys object representation

func (PubKeys) Aggregate

func (keys PubKeys) Aggregate() bls.PublicKey

Aggregate iterates over public keys and adds them to the bls PublicKey

type Share

type Share struct {
	NodeID       uint64
	PublicKey    *bls.PublicKey
	Committee    map[uint64]*proto.Node
	Metadata     *beacon.ValidatorMetadata // pointer in order to support nil
	OwnerAddress string
	Operators    [][]byte
}

Share storage model

func (*Share) CommitteeSize

func (s *Share) CommitteeSize() int

CommitteeSize returns the IBFT committee size

func (*Share) Deserialize

func (s *Share) Deserialize(obj basedb.Obj) (*Share, error)

Deserialize key/value to Share model

func (*Share) HasMetadata added in v0.0.20

func (s *Share) HasMetadata() bool

HasMetadata returns true if the validator metadata was fetched

func (*Share) HashOperators added in v0.1.9

func (s *Share) HashOperators() []string

HashOperators hash all Operators keys key

func (*Share) IsOperatorShare added in v0.1.11

func (s *Share) IsOperatorShare(operatorPubKey string) bool

IsOperatorShare checks whether the share belongs to operator

func (*Share) OperatorPubKey added in v0.1.4

func (s *Share) OperatorPubKey() (*bls.PublicKey, error)

OperatorPubKey returns the operator's public key based on the node id

func (*Share) OperatorReady added in v0.1.5

func (s *Share) OperatorReady() bool

OperatorReady returns true if all operator relevant data (node id, secret share, etc.) is present

func (*Share) PartialThresholdSize added in v0.0.14

func (s *Share) PartialThresholdSize() int

PartialThresholdSize returns the minimum IBFT committee members that needs to sign for a partial quorum (F+1)

func (*Share) PubKeysByID

func (s *Share) PubKeysByID(ids []uint64) (PubKeys, error)

PubKeysByID returns the public keys with the associated ids

func (*Share) Serialize

func (s *Share) Serialize() ([]byte, error)

Serialize share to []byte

func (*Share) SetOperators added in v0.1.9

func (s *Share) SetOperators(ops [][]byte)

SetOperators set Operators public keys

func (*Share) ThresholdSize

func (s *Share) ThresholdSize() int

ThresholdSize returns the minimum IBFT committee members that needs to sign for a quorum (2F+1)

func (*Share) VerifySignedMessage

func (s *Share) VerifySignedMessage(msg *proto.SignedMessage) error

VerifySignedMessage returns true of signed message verifies against pks

type ShareOptions

type ShareOptions struct {
	NodeID       uint64         `yaml:"NodeID" env:"NodeID" env-description:"Local share node ID"`
	PublicKey    string         `yaml:"PublicKey" env:"LOCAL_NODE_ID" env-description:"Local validator public key"`
	ShareKey     string         `yaml:"ShareKey" env:"LOCAL_SHARE_KEY" env-description:"Local share key"`
	Committee    map[string]int `yaml:"Committee" env:"LOCAL_COMMITTEE" env-description:"Local validator committee array"`
	OwnerAddress string         `yaml:"OwnerAddress" env:"LOCAL_OWNER_ADDRESS" env-description:"Local validator owner address"`
	Operators    []string       `yaml:"Operators" env:"LOCAL_OPERATORS" env-description:"Local validator selected operators"`
}

ShareOptions - used to load validator share from config

func (*ShareOptions) ToShare

func (options *ShareOptions) ToShare() (*Share, error)

ToShare creates a Share instance from ShareOptions

Jump to

Keyboard shortcuts

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