Documentation
¶
Index ¶
- type DRand
- func (dRand *DRand) IsValidatorInCommittee(validatorBlsPubKey string) bool
- func (dRand *DRand) ProcessMessageLeader(payload []byte)
- func (dRand *DRand) ProcessMessageValidator(payload []byte)
- func (dRand *DRand) ResetState()
- func (dRand *DRand) SetLeaderPubKey(k []byte) error
- func (dRand *DRand) UpdatePublicKeys(pubKeys []*bls.PublicKey) int
- func (dRand *DRand) WaitForEpochBlock(blockChannel chan *types.Block, stopChan chan struct{}, ...)
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 ¶
IsValidatorInCommittee returns whether the given validator BLS address is part of my committee
func (*DRand) ProcessMessageLeader ¶
ProcessMessageLeader dispatches messages for the leader to corresponding processors.
func (*DRand) ProcessMessageValidator ¶
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 ¶
SetLeaderPubKey deserialize the public key of drand leader
func (*DRand) UpdatePublicKeys ¶
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