Documentation ¶
Index ¶
- Constants
- func RemoteAddress(c context.Context) string
- type CallOption
- type CertManager
- type Client
- type ControlClient
- func (c *ControlClient) ChainInfo() (*control.ChainInfoPacket, error)
- func (c *ControlClient) GroupFile() (*control.GroupPacket, error)
- func (c *ControlClient) InitDKG(leader Peer, entropy *control.EntropyInfo, secret string) (*control.GroupPacket, error)
- func (c *ControlClient) InitDKGLeader(nodes, threshold int, beaconPeriod, catchupPeriod, timeout time.Duration, ...) (*control.GroupPacket, error)
- func (c *ControlClient) InitReshare(leader Peer, secret, oldPath string, force bool) (*control.GroupPacket, error)
- func (c *ControlClient) InitReshareLeader(nodes, threshold int, timeout, catchupPeriod time.Duration, ...) (*control.GroupPacket, error)
- func (c *ControlClient) Ping() error
- func (c *ControlClient) PrivateKey() (*control.PrivateKeyResponse, error)
- func (c *ControlClient) PublicKey() (*control.PublicKeyResponse, error)
- func (c *ControlClient) Share() (*control.ShareResponse, error)
- func (c *ControlClient) Shutdown() (*control.ShutdownResponse, error)
- func (c *ControlClient) StartFollowChain(cc ctx.Context, hash string, nodes []string, tls bool, upTo uint64) (outCh chan *control.FollowProgress, errCh chan error, e error)
- type ControlListener
- type DefaultControlServer
- func (s *DefaultControlServer) ChainInfo(c ctx.Context, in *control.ChainInfoRequest) (*control.ChainInfoPacket, error)
- func (s *DefaultControlServer) PingPong(c ctx.Context, in *control.Ping) (*control.Pong, error)
- func (s *DefaultControlServer) PrivateKey(c ctx.Context, in *control.PrivateKeyRequest) (*control.PrivateKeyResponse, error)
- func (s *DefaultControlServer) PublicKey(c ctx.Context, in *control.PublicKeyRequest) (*control.PublicKeyResponse, error)
- func (s *DefaultControlServer) Share(c ctx.Context, in *control.ShareRequest) (*control.ShareResponse, error)
- type HTTPClient
- type HexJSON
- func (*HexJSON) ContentType() string
- func (j *HexJSON) Delimiter() []byte
- func (j *HexJSON) Marshal(v interface{}) ([]byte, error)
- func (j *HexJSON) NewDecoder(r io.Reader) runtime.Decoder
- func (j *HexJSON) NewEncoder(w io.Writer) runtime.Encoder
- func (j *HexJSON) Unmarshal(data []byte, v interface{}) error
- type Listener
- type Peer
- type PrivateGateway
- type ProtocolClient
- type PublicClient
- type PublicGateway
- type Service
Constants ¶
const MaxSyncBuffer = 100
MaxSyncBuffer is the maximum number of queued rounds when syncing
Variables ¶
This section is empty.
Functions ¶
func RemoteAddress ¶ added in v1.1.2
RemoteAddress returns the address of the peer by first taking the address that gRPC returns. If that address is a reserved address, then it tries to read the "X-REAL-IP" header content. For example, a valid nging config could include
```
location / { grpc_pass grpc://127.0.0.1:9091; grpc_set_header X-Real-IP $remote_addr; }
```
Types ¶
type CallOption ¶ added in v0.3.7
type CallOption = grpc.CallOption
CallOption is simply a wrapper around the grpc options
type CertManager ¶ added in v0.3.7
type CertManager struct {
// contains filtered or unexported fields
}
CertManager is used to managed certificates. It is most commonly used for testing with self signed certificate. By default, it returns the bundled set of certificates coming with the OS (Go's implementation).
func NewCertManager ¶ added in v0.3.7
func NewCertManager() *CertManager
NewCertManager returns a cert manager filled with the trusted certificates of the running system
func (*CertManager) Add ¶ added in v0.3.7
func (p *CertManager) Add(certPath string) error
Add tries to add the certificate at the given path to the pool and returns an error otherwise
func (*CertManager) Pool ¶ added in v0.3.7
func (p *CertManager) Pool() *x509.CertPool
Pool returns the pool of trusted certificates
type Client ¶
type Client interface { ProtocolClient PublicClient HTTPClient }
Client implements methods to call on the protocol API and the public API of a drand node
func NewGrpcClient ¶
func NewGrpcClient(opts ...grpc.DialOption) Client
NewGrpcClient returns an implementation of an InternalClient and ExternalClient using gRPC connections
func NewGrpcClientFromCertManager ¶ added in v0.3.7
func NewGrpcClientFromCertManager(c *CertManager, opts ...grpc.DialOption) Client
NewGrpcClientFromCertManager returns a Client using gRPC with the given trust store of certificates.
func NewGrpcClientWithTimeout ¶ added in v0.3.6
func NewGrpcClientWithTimeout(timeout time.Duration, opts ...grpc.DialOption) Client
NewGrpcClientWithTimeout returns a Client using gRPC using fixed timeout for method calls.
type ControlClient ¶ added in v0.4.0
type ControlClient struct {
// contains filtered or unexported fields
}
ControlClient is a struct that implement control.ControlClient and is used to request a Share to a ControlListener on a specific port
func NewControlClient ¶ added in v0.4.0
func NewControlClient(addr string) (*ControlClient, error)
NewControlClient creates a client capable of issuing control commands to a localhost running drand node.
func (*ControlClient) ChainInfo ¶ added in v1.1.2
func (c *ControlClient) ChainInfo() (*control.ChainInfoPacket, error)
ChainInfo returns the collective key of the remote node
func (*ControlClient) GroupFile ¶ added in v0.5.5
func (c *ControlClient) GroupFile() (*control.GroupPacket, error)
GroupFile returns the group file that the drand instance uses at the current time
func (*ControlClient) InitDKG ¶ added in v0.4.0
func (c *ControlClient) InitDKG(leader Peer, entropy *control.EntropyInfo, secret string) (*control.GroupPacket, error)
InitDKG sets up the node to be ready for a first DKG protocol.
func (*ControlClient) InitDKGLeader ¶ added in v1.1.2
func (c *ControlClient) InitDKGLeader(nodes, threshold int, beaconPeriod, catchupPeriod, timeout time.Duration, entropy *control.EntropyInfo, secret string, offset int) (*control.GroupPacket, error)
InitDKGLeader sets up the node to be ready for a first DKG protocol. groupPart NOTE: only group referral via filesystem path is supported at the moment. XXX Might be best to move to core/
func (*ControlClient) InitReshare ¶ added in v0.4.0
func (c *ControlClient) InitReshare(leader Peer, secret, oldPath string, force bool) (*control.GroupPacket, error)
InitReshare sets up the node to be ready for a resharing protocol.
func (*ControlClient) InitReshareLeader ¶ added in v1.1.2
func (c *ControlClient) InitReshareLeader( nodes, threshold int, timeout, catchupPeriod time.Duration, secret, oldPath string, offset int) (*control.GroupPacket, error)
InitReshareLeader sets up the node to be ready for a resharing protocol. NOTE: only group referral via filesystem path is supported at the moment. XXX Might be best to move to core/
func (*ControlClient) Ping ¶ added in v0.4.0
func (c *ControlClient) Ping() error
Ping the drand daemon to check if it's up and running
func (*ControlClient) PrivateKey ¶ added in v0.4.0
func (c *ControlClient) PrivateKey() (*control.PrivateKeyResponse, error)
PrivateKey returns the private key of the remote node
func (*ControlClient) PublicKey ¶ added in v0.4.0
func (c *ControlClient) PublicKey() (*control.PublicKeyResponse, error)
PublicKey returns the public key of the remote node
func (*ControlClient) Share ¶ added in v0.4.0
func (c *ControlClient) Share() (*control.ShareResponse, error)
Share returns the share of the remote node
func (*ControlClient) Shutdown ¶ added in v0.5.5
func (c *ControlClient) Shutdown() (*control.ShutdownResponse, error)
Shutdown stops the daemon
func (*ControlClient) StartFollowChain ¶ added in v1.1.2
func (c *ControlClient) StartFollowChain(cc ctx.Context, hash string, nodes []string, tls bool, upTo uint64) (outCh chan *control.FollowProgress, errCh chan error, e error)
StartFollowChain initates the client catching up on an existing chain it is not part of
type ControlListener ¶ added in v0.4.0
type ControlListener struct {
// contains filtered or unexported fields
}
ControlListener is used to keep state of the connections of our drand instance
func NewTCPGrpcControlListener ¶ added in v0.4.0
func NewTCPGrpcControlListener(s control.ControlServer, controlAddr string) ControlListener
NewTCPGrpcControlListener registers the pairing between a ControlServer and a grpx server
func (*ControlListener) Start ¶ added in v0.4.0
func (g *ControlListener) Start()
Start the listener for the control commands
func (*ControlListener) Stop ¶ added in v0.4.0
func (g *ControlListener) Stop()
Stop the listener and connections
type DefaultControlServer ¶ added in v0.4.0
type DefaultControlServer struct {
C control.ControlServer
}
DefaultControlServer implements the functionalities of Control Service, and just as Default Service, it is used for testing.
func (*DefaultControlServer) ChainInfo ¶ added in v1.1.2
func (s *DefaultControlServer) ChainInfo(c ctx.Context, in *control.ChainInfoRequest) (*control.ChainInfoPacket, error)
ChainInfo gets the current chain information from the ndoe
func (*DefaultControlServer) PrivateKey ¶ added in v0.4.0
func (s *DefaultControlServer) PrivateKey(c ctx.Context, in *control.PrivateKeyRequest) (*control.PrivateKeyResponse, error)
PrivateKey gets the node's private key
func (*DefaultControlServer) PublicKey ¶ added in v0.4.0
func (s *DefaultControlServer) PublicKey(c ctx.Context, in *control.PublicKeyRequest) (*control.PublicKeyResponse, error)
PublicKey gets the node's public key
func (*DefaultControlServer) Share ¶ added in v0.4.0
func (s *DefaultControlServer) Share(c ctx.Context, in *control.ShareRequest) (*control.ShareResponse, error)
Share initiates a share request
type HTTPClient ¶ added in v1.1.2
HTTPClient is an optional extension to the protocol client relaying of HTTP over the GRPC connection. it is currently used for relaying metrics between group members.
type HexJSON ¶ added in v0.4.0
type HexJSON struct{}
HexJSON transforms json into hex string instead of b64
func (*HexJSON) ContentType ¶ added in v0.4.0
ContentType always Returns "application/json".
func (*HexJSON) NewDecoder ¶ added in v0.4.0
NewDecoder returns a Decoder which reads JSON stream from "r".
func (*HexJSON) NewEncoder ¶ added in v0.4.0
NewEncoder returns an Encoder which writes JSON stream into "w".
type Listener ¶
Listener is the active listener for incoming requests.
func NewGRPCListenerForPrivate ¶ added in v1.1.2
func NewGRPCListenerForPrivate( ctx context.Context, bindingAddr, certPath, keyPath string, s Service, insecure bool, opts ...grpc.ServerOption) (Listener, error)
NewGRPCListenerForPrivate creates a new listener for the Public and Protocol APIs over GRPC.
type Peer ¶
Peer is a simple interface that allows retrieving the address of a destination. It might further be enhanced with certificates properties and all.
func CreatePeer ¶ added in v1.1.2
CreatePeer creates a peer from an address
type PrivateGateway ¶ added in v1.1.2
type PrivateGateway struct { Listener ProtocolClient PublicClient }
PrivateGateway is the main interface to communicate to other drand nodes. It acts as a listener to receive incoming requests and acts a client connecting to drand particpants. The gateway fixes all drand functionalities offered by drand.
func NewGRPCPrivateGateway ¶ added in v1.1.2
func NewGRPCPrivateGateway(ctx context.Context, listen, certPath, keyPath string, certs *CertManager, s Service, insecure bool, opts ...grpc.DialOption) (*PrivateGateway, error)
NewGRPCPrivateGateway returns a grpc gateway listening on "listen" for the public methods, listening on "port" for the control methods, using the given Service s with the given options.
func (*PrivateGateway) StartAll ¶ added in v1.1.2
func (g *PrivateGateway) StartAll()
StartAll starts the control and public functionalities of the node
func (*PrivateGateway) StopAll ¶ added in v1.1.2
func (g *PrivateGateway) StopAll(ctx context.Context)
StopAll stops the control and public functionalities of the node
type ProtocolClient ¶ added in v0.5.5
type ProtocolClient interface { GetIdentity(ctx context.Context, p Peer, in *drand.IdentityRequest, opts ...CallOption) (*drand.Identity, error) SyncChain(ctx context.Context, p Peer, in *drand.SyncRequest, opts ...CallOption) (chan *drand.BeaconPacket, error) PartialBeacon(ctx context.Context, p Peer, in *drand.PartialBeaconPacket, opts ...CallOption) error BroadcastDKG(c context.Context, p Peer, in *drand.DKGPacket, opts ...CallOption) error SignalDKGParticipant(ctx context.Context, p Peer, in *drand.SignalDKGPacket, opts ...CallOption) error PushDKGInfo(ctx context.Context, p Peer, in *drand.DKGInfoPacket, opts ...grpc.CallOption) error }
ProtocolClient holds all the methods of the protocol API that drand protocols use. See protobuf/drand/protocol.proto for more information.
type PublicClient ¶ added in v0.5.5
type PublicClient interface { PublicRandStream(ctx context.Context, p Peer, in *drand.PublicRandRequest, opts ...CallOption) (chan *drand.PublicRandResponse, error) PublicRand(ctx context.Context, p Peer, in *drand.PublicRandRequest) (*drand.PublicRandResponse, error) PrivateRand(ctx context.Context, p Peer, in *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error) ChainInfo(ctx context.Context, p Peer, in *drand.ChainInfoRequest) (*drand.ChainInfoPacket, error) Home(ctx context.Context, p Peer, in *drand.HomeRequest) (*drand.HomeResponse, error) }
PublicClient holds all the methods of the public API . See `protobuf/drand/public.proto` for more information.
type PublicGateway ¶ added in v1.1.2
type PublicGateway struct {
Listener
}
PublicGateway is the main interface to communicate to users. The gateway fixes all drand functionalities offered by drand.
func NewRESTPublicGateway ¶ added in v1.1.2
func NewRESTPublicGateway( ctx context.Context, listen, certPath, keyPath string, certs *CertManager, handler http.Handler, insecure bool) (*PublicGateway, error)
NewRESTPublicGateway returns a grpc gateway listening on "listen" for the public methods, listening on "port" for the control methods, using the given Service s with the given options.
func (*PublicGateway) StartAll ¶ added in v1.1.2
func (g *PublicGateway) StartAll()
StartAll starts the control and public functionalities of the node
func (*PublicGateway) StopAll ¶ added in v1.1.2
func (g *PublicGateway) StopAll(ctx context.Context)
StopAll stops the control and public functionalities of the node
type Service ¶
type Service interface { drand.PublicServer drand.ControlServer drand.ProtocolServer }
Service holds all functionalities that a drand node should implement