storage

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: GPL-3.0 Imports: 9 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) GetAllValidatorsShare

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

GetAllValidatorsShare returns ALL validators shares from db

func (*Collection) GetValidatorsShare

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

GetValidatorsShare by key

func (*Collection) LoadFromConfig

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

LoadFromConfig fetch validator share from config and save it to db

func (*Collection) LoadMultipleFromConfig

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

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) error
	LoadFromConfig(options ShareOptions) error
	SaveValidatorShare(share *Share) error
	GetValidatorsShare(key []byte) (*Share, error)
	GetAllValidatorsShare() ([]*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
	Index     *uint64 // pointer in order to support nil
	ShareKey  *bls.SecretKey
	Committee map[uint64]*proto.Node
}

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) 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

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