drand

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DRand

type DRand struct {
	ConfirmedBlockChannel chan *types.Block // Channel to receive confirmed blocks
	PRndChannel           chan []byte       // Channel to send pRnd (preimage of randomness resulting from combined vrf randomnesses) to consensus. The first 32 bytes are randomness, the rest is for bitmap.
	RndChannel            chan [64]byte     // Channel for DRG protocol to send the final randomness to consensus. The first 32 bytes are the randomness and the last 32 bytes are the hash of the block where the corresponding pRnd was generated

	// Public keys of the committee including leader and validators
	PublicKeys []*bls.PublicKey
	// The addresses of my committee
	CommitteePublicKeys map[string]bool

	// Whether I am leader. False means I am validator
	IsLeader bool

	// Leader or validator address
	SelfAddress string

	// Shard Id which this node belongs to
	ShardID uint32
	// contains filtered or unexported fields
}

DRand is the main struct which contains state for the distributed randomness protocol.

func New

func New(host p2p.Host, ShardID uint32, peers []p2p.Peer, leader p2p.Peer, confirmedBlockChannel chan *types.Block, blsPriKey *bls.SecretKey) *DRand

New creates a new dRand object

func (*DRand) IsValidatorInCommittee

func (dRand *DRand) IsValidatorInCommittee(validatorBlsPubKey string) bool

IsValidatorInCommittee returns whether the given validator BLS address is part of my committee

func (*DRand) ProcessMessageLeader

func (dRand *DRand) ProcessMessageLeader(payload []byte)

ProcessMessageLeader dispatches messages for the leader to corresponding processors.

func (*DRand) ProcessMessageValidator

func (dRand *DRand) ProcessMessageValidator(payload []byte)

ProcessMessageValidator dispatches messages for the validator to corresponding processors.

func (*DRand) ResetState

func (dRand *DRand) ResetState()

ResetState resets the state of the randomness protocol

func (*DRand) SetLeaderPubKey

func (dRand *DRand) SetLeaderPubKey(k []byte) error

SetLeaderPubKey deserialize the public key of drand leader

func (*DRand) UpdatePublicKeys

func (dRand *DRand) UpdatePublicKeys(pubKeys []*bls.PublicKey) int

UpdatePublicKeys updates the PublicKeys variable, protected by a mutex

func (*DRand) WaitForEpochBlock

func (dRand *DRand) WaitForEpochBlock(blockChannel chan *types.Block, stopChan chan struct{}, stoppedChan chan struct{})

WaitForEpochBlock waits for the first epoch block to run DRG on

Jump to

Keyboard shortcuts

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