storage

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: GPL-3.0 Imports: 11 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) CleanAllShares added in v0.0.18

func (s *Collection) CleanAllShares() error

CleanAllShares cleans all existing shares from DB

func (*Collection) GetAllValidatorsShare

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

GetAllValidatorsShare returns all shares

func (*Collection) GetValidatorShare added in v0.0.18

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

GetValidatorShare by key

func (*Collection) LoadFromConfig

func (s *Collection) LoadFromConfig(options ShareOptions) (string, error)

LoadFromConfig fetch validator share from config and save it to db

func (*Collection) LoadMultipleFromConfig

func (s *Collection) LoadMultipleFromConfig(items []ShareOptions)

LoadMultipleFromConfig fetch multiple validators share from config and save it to db

func (*Collection) SaveValidatorShare

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

SaveValidatorShare save validator share to db

type CollectionOptions

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

CollectionOptions struct

type ICollection

type ICollection interface {
	LoadMultipleFromConfig(items []ShareOptions)
	LoadFromConfig(options ShareOptions) (string, error)
	SaveValidatorShare(share *Share) error
	GetValidatorShare(key []byte) (*Share, bool, error)
	GetAllValidatorsShare() ([]*Share, error)
	CleanAllShares() 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
	ShareKey  *bls.SecretKey
	Committee map[uint64]*proto.Node
	Metadata  *beacon.ValidatorMetadata // pointer in order to support nil
}

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) 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) 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"`
}

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