grpc

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0, MIT Imports: 14 Imported by: 2

Documentation

Overview

Package grpc provides a drand client implementation that uses drand's gRPC API.

The client connects to a drand gRPC endpoint to fetch randomness. The gRPC client has some advantages over the HTTP client - it is more compact on-the-wire and supports streaming and authentication.

Example:

package main

import (
	"encoding/hex"

	"github.com/drand/drand/client"
	"github.com/drand/drand/client/grpc"
)

const (
	grpcAddr = "example.drand.grpc.server:4444"
	certPath = "/path/to/drand-grpc.cert"
)

var chainHash, _ = hex.DecodeString("8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce")

func main() {
	gc, err := grpc.New(grpcAddr, certPath, false)

	c, err := client.New(
		client.From(gc),
		client.WithChainHash(chainHash),
	)
}

A path to a file that holds TLS credentials for the drand server is required to validate server connections. Alternatively set the final parameter to `true` to enable _insecure_ connections (not recommended).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(address, certPath string, insecure bool, chainHash []byte) (client.Client, error)

New creates a drand client backed by a GRPC connection.

Types

This section is empty.

Jump to

Keyboard shortcuts

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