Documentation
¶
Index ¶
- Constants
- Variables
- type CallbackStore
- type Config
- type CryptoSafe
- type Handler
- func (h *Handler) AddCallback(id string, fn func(*chain.Beacon))
- func (h *Handler) Catchup()
- func (h *Handler) ProcessPartialBeacon(c context.Context, p *proto.PartialBeaconPacket) (*proto.Empty, error)
- func (h *Handler) RemoveCallback(id string)
- func (h *Handler) Start() error
- func (h *Handler) Stop()
- func (h *Handler) StopAt(stopTime int64) error
- func (h *Handler) Store() chain.Store
- func (h *Handler) SyncChain(req *proto.SyncRequest, stream proto.Protocol_SyncChainServer) error
- func (h *Handler) Transition(prevGroup *key.Group) error
- func (h *Handler) TransitionNewGroup(newShare *key.Share, newGroup *key.Group)
- type Syncer
Constants ¶
const CallbackWorkerQueue = 100
CallbackWorkerQueue is the length of the channel that the callback worker uses to dispatch beacons to its workers.
const MaxCatchupBuffer = 1000
MaxCatchupBuffer is the maximum size of the channel that receives beacon from a sync mechanism.
const MaxPartialsPerNode = 100
MaxPartialsPerNode is the maximum number of partials the cache stores about any node at any given time. This constant could be much lower, 3 for example but when the network is catching up, it may happen that some nodes goes much faster than other. In that case, multiple partials can be received from a fast nodes and these are valid.
Variables ¶
var MaxSyncWaitTime = 2 * time.Second
MaxSyncWaitTime sets how long we'll wait after a new connection to receive new beacons from one peer
Functions ¶
This section is empty.
Types ¶
type CallbackStore ¶
type CallbackStore interface { chain.Store AddCallback(id string, fn func(*chain.Beacon)) RemoveCallback(id string) }
CallbackStore is an interface that allows to register callbacks that gets called each time a new beacon is inserted
func NewCallbackStore ¶
func NewCallbackStore(s chain.Store) CallbackStore
NewCallbackStore returns a Store that uses a pool of worker to dispatch the beacon to the registered callbacks. The callbacks are not called if the "Put" operations failed.
type Config ¶
type Config struct { // Public key of this node Public *key.Node Share *key.Share // Group listing all nodes and public key of the network Group *key.Group // Clock to use - useful to testing Clock clock.Clock }
Config holds the different cryptographc informations necessary to run the randomness beacon.
type CryptoSafe ¶
type CryptoSafe interface { // SignPartial returns the partial signature SignPartial(msg []byte) ([]byte, error) }
CryptoSafe holds the cryptographic information to generate a partial beacon
type Handler ¶
Handler holds the logic to initiate, and react to the TBLS protocol. Each time a full signature can be recosntructed, it saves it to the given Store.
func NewHandler ¶
NewHandler returns a fresh handler ready to serve and create randomness beacon
func (*Handler) AddCallback ¶
AddCallback is a proxy method to register a callback on the backend store
func (*Handler) Catchup ¶
func (h *Handler) Catchup()
Catchup waits the next round's time to participate. This method is called when a node stops its daemon (maintenance or else) and get backs in the already running network . If the node does not have the previous randomness, it sync its local chain with other nodes to be able to participate in the next upcoming round.
func (*Handler) ProcessPartialBeacon ¶
func (h *Handler) ProcessPartialBeacon(c context.Context, p *proto.PartialBeaconPacket) (*proto.Empty, error)
ProcessPartialBeacon receives a request for a beacon partial signature. It forwards it to the round manager if it is a valid beacon.
func (*Handler) RemoveCallback ¶
RemoveCallback is a proxy method to remove a callback on the backend store
func (*Handler) Start ¶
Start runs the beacon protocol (threshold BLS signature). The first round will sign the message returned by the config.FirstRound() function. If the genesis time specified in the group is already passed, Start returns an error. In that case, if the group is already running, you should call SyncAndRun(). Round 0 = genesis seed - fixed Round 1 starts at genesis time, and is signing over the genesis seed
func (*Handler) Stop ¶
func (h *Handler) Stop()
Stop the beacon loop from aggregating further randomness, but it finishes the one it is aggregating currently.
func (*Handler) StopAt ¶
StopAt will stop the handler at the given time. It is useful when transitionining for a resharing.
func (*Handler) SyncChain ¶
func (h *Handler) SyncChain(req *proto.SyncRequest, stream proto.Protocol_SyncChainServer) error
SyncChain is a proxy method to sync a chain
func (*Handler) Transition ¶
Transition makes this beacon continuously sync until the time written in the "TransitionTime" in the handler's group file, where he will start generating randomness. To sync, he contact the nodes listed in the previous group file given.
type Syncer ¶
type Syncer interface { // Follow is a blocking call that continuously fetches the beacon from the // given nodes, verify the validity (chain etc) and then stores it, until // the context is canceled or the round reaches upTo. To follow // indefinitely, simply pass upTo = 0. Follow(c context.Context, upTo uint64, to []net.Peer) error // Syncing returns true if the syncer is currently being syncing Syncing() bool // SyncChain imeplements the server side of the syncing process SyncChain(req *proto.SyncRequest, p proto.Protocol_SyncChainServer) error }
Syncer allows to follow a chain from other nodes and replies to syncing requests.
func NewSyncer ¶
func NewSyncer(l log.Logger, s CallbackStore, info *chain.Info, client net.ProtocolClient) Syncer
NewSyncer returns a syncer implementation