proto

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const LevelNotSet = -1

LevelNotSet is the zero value level used to indicate that no level (and thereby no reply) has been set for a correctable quorum call.

Variables

View Source
var Error = func(n1, n2 *Node) bool {
	if n1.lastErr != nil && n2.lastErr == nil {
		return false
	}
	return true
}

Error sorts nodes by their LastErr() status in increasing order. A node with LastErr() != nil is larger than a node with LastErr() == nil.

View Source
var File_internal_proto_hotstuff_proto protoreflect.FileDescriptor
View Source
var ID = func(n1, n2 *Node) bool {
	return n1.id < n2.id
}

ID sorts nodes by their identifier in increasing order.

View Source
var Latency = func(n1, n2 *Node) bool {
	if n1.latency < 0 {
		return false
	}
	return n1.latency < n2.latency
}

Latency sorts nodes by latency in increasing order. Latencies less then zero (sentinel value) are considered greater than any positive latency.

View Source
var Port = func(n1, n2 *Node) bool {
	p1, _ := strconv.Atoi(n1.Port())
	p2, _ := strconv.Atoi(n2.Port())
	return p1 < p2
}

Port sorts nodes by their port number in increasing order. Warning: This function may be removed in the future.

Functions

func Equal

func Equal(a, b *Configuration) bool

Equal returns a boolean reporting whether a and b represents the same configuration.

func ManagerCreationError

func ManagerCreationError(err error) error

ManagerCreationError returns an error reporting that a Manager could not be created due to err.

Types

type Block

type Block struct {
	ParentHash []byte      `protobuf:"bytes,1,opt,name=ParentHash,proto3" json:"ParentHash,omitempty"`
	QC         *QuorumCert `protobuf:"bytes,2,opt,name=QC,proto3" json:"QC,omitempty"`
	Height     int64       `protobuf:"varint,3,opt,name=Height,proto3" json:"Height,omitempty"`
	Commands   []*Command  `protobuf:"bytes,4,rep,name=Commands,proto3" json:"Commands,omitempty"`
	// contains filtered or unexported fields
}

func BlockToProto

func BlockToProto(n *data.Block) *Block

func (*Block) Descriptor deprecated

func (*Block) Descriptor() ([]byte, []int)

Deprecated: Use Block.ProtoReflect.Descriptor instead.

func (*Block) FromProto

func (pn *Block) FromProto() *data.Block

func (*Block) GetCommands

func (x *Block) GetCommands() []*Command

func (*Block) GetHeight

func (x *Block) GetHeight() int64

func (*Block) GetParentHash

func (x *Block) GetParentHash() []byte

func (*Block) GetQC

func (x *Block) GetQC() *QuorumCert

func (*Block) ProtoMessage

func (*Block) ProtoMessage()

func (*Block) ProtoReflect

func (x *Block) ProtoReflect() protoreflect.Message

func (*Block) Reset

func (x *Block) Reset()

func (*Block) String

func (x *Block) String() string

type Command

type Command struct {
	Data []byte `protobuf:"bytes,1,opt,name=Data,proto3" json:"Data,omitempty"`
	// contains filtered or unexported fields
}

func CommandToProto

func CommandToProto(cmd data.Command) *Command

func (*Command) Descriptor deprecated

func (*Command) Descriptor() ([]byte, []int)

Deprecated: Use Command.ProtoReflect.Descriptor instead.

func (*Command) FromProto

func (cmd *Command) FromProto() data.Command

func (*Command) GetData

func (x *Command) GetData() []byte

func (*Command) ProtoMessage

func (*Command) ProtoMessage()

func (*Command) ProtoReflect

func (x *Command) ProtoReflect() protoreflect.Message

func (*Command) Reset

func (x *Command) Reset()

func (*Command) String

func (x *Command) String() string

type ConfigNotFoundError

type ConfigNotFoundError uint32

A ConfigNotFoundError reports that a specified configuration could not be found.

func (ConfigNotFoundError) Error

func (e ConfigNotFoundError) Error() string

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

A Configuration represents a static set of nodes on which quorum remote procedure calls may be invoked.

func NewConfig

func NewConfig(qspec QuorumSpec, opts ...ManagerOption) (*Configuration, func(), error)

NewConfig returns a configuration for the given node addresses and quorum spec. The returned func() must be called to close the underlying connections. This is an experimental API.

func (*Configuration) ID

func (c *Configuration) ID() uint32

ID reports the identifier for the configuration.

func (*Configuration) NodeIDs

func (c *Configuration) NodeIDs() []uint32

NodeIDs returns a slice containing the local ids of all the nodes in the configuration. IDs are returned in the same order as they were provided in the creation of the Configuration.

func (*Configuration) Nodes

func (c *Configuration) Nodes() []*Node

Nodes returns a slice of each available node. IDs are returned in the same order as they were provided in the creation of the Configuration.

func (*Configuration) Propose

func (c *Configuration) Propose(in *Block) error

Propose is a one-way multicast call on all nodes in configuration c, with the same in argument. The call is asynchronous and has no return value.

func (*Configuration) Size

func (c *Configuration) Size() int

Size returns the number of nodes in the configuration.

func (*Configuration) String

func (c *Configuration) String() string

func (*Configuration) SubError

func (c *Configuration) SubError() <-chan GRPCError

SubError returns a channel for listening to individual node errors. Currently only a single listener is supported.

type GRPCError

type GRPCError struct {
	NodeID uint32
	Cause  error
}

GRPCError is used to report that a single gRPC call failed.

func (GRPCError) Error

func (e GRPCError) Error() string

type GorumsServer

type GorumsServer struct {
	// contains filtered or unexported fields
}

GorumsServer serves all ordering based RPCs using registered handlers.

func NewGorumsServer

func NewGorumsServer(opts ...ServerOption) *GorumsServer

NewGorumsServer returns a new instance of GorumsServer.

func (*GorumsServer) GracefulStop

func (s *GorumsServer) GracefulStop()

GracefulStop waits for all RPCs to finish before stopping.

func (*GorumsServer) RegisterHotstuffServer

func (s *GorumsServer) RegisterHotstuffServer(srv Hotstuff)

func (*GorumsServer) Serve

func (s *GorumsServer) Serve(listener net.Listener) error

Serve starts serving on the listener.

func (*GorumsServer) Stop

func (s *GorumsServer) Stop()

Stop stops the server immediately.

type Hotstuff

type Hotstuff interface {
	Propose(context.Context, *Block)
	Vote(context.Context, *PartialCert)
	NewView(context.Context, *QuorumCert)
}

Hotstuff is the server-side API for the Hotstuff Service

type IllegalConfigError

type IllegalConfigError string

An IllegalConfigError reports that a specified configuration could not be created.

func (IllegalConfigError) Error

func (e IllegalConfigError) Error() string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages a pool of node configurations on which quorum remote procedure calls can be made.

func NewManager

func NewManager(opts ...ManagerOption) (*Manager, error)

NewManager attempts to connect to the given set of node addresses and if successful returns a new Manager containing connections to those nodes.

func (*Manager) AddNode

func (m *Manager) AddNode(addr string) error

AddNode attempts to dial to the provide node address. The node is added to the Manager's pool of nodes if a connection was established.

func (*Manager) Close

func (m *Manager) Close()

Close closes all node connections and any client streams.

func (*Manager) Configuration

func (m *Manager) Configuration(id uint32) (config *Configuration, found bool)

Configuration returns the configuration with the given global identifier if present.

func (*Manager) ConfigurationIDs

func (m *Manager) ConfigurationIDs() []uint32

ConfigurationIDs returns the identifier of each available configuration.

func (*Manager) Configurations

func (m *Manager) Configurations() []*Configuration

Configurations returns a slice of each available configuration.

func (*Manager) NewConfiguration

func (m *Manager) NewConfiguration(ids []uint32, qspec QuorumSpec) (*Configuration, error)

NewConfiguration returns a new configuration given quorum specification and a timeout.

func (*Manager) Node

func (m *Manager) Node(id uint32) (node *Node, found bool)

Node returns the node with the given identifier if present.

func (*Manager) NodeIDs

func (m *Manager) NodeIDs() []uint32

NodeIDs returns the identifier of each available node. IDs are returned in the same order as they were provided in the creation of the Manager.

func (*Manager) Nodes

func (m *Manager) Nodes() []*Node

Nodes returns a slice of each available node. IDs are returned in the same order as they were provided in the creation of the Manager.

func (*Manager) Size

func (m *Manager) Size() (nodes, configs int)

Size returns the number of nodes and configurations in the Manager.

type ManagerOption

type ManagerOption func(*managerOptions)

ManagerOption provides a way to set different options on a new Manager.

func WithBackoff

func WithBackoff(backoff backoff.Config) ManagerOption

WithBackoff allows for changing the backoff delays used by Gorums.

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) ManagerOption

WithDialTimeout returns a ManagerOption which is used to set the dial context timeout to be used when initially connecting to each node in its pool.

func WithGrpcDialOptions

func WithGrpcDialOptions(opts ...grpc.DialOption) ManagerOption

WithGrpcDialOptions returns a ManagerOption which sets any gRPC dial options the Manager should use when initially connecting to each node in its pool.

func WithLogger

func WithLogger(logger *log.Logger) ManagerOption

WithLogger returns a ManagerOption which sets an optional error logger for the Manager.

func WithMetadata

func WithMetadata(md metadata.MD) ManagerOption

WithMetadata returns a ManagerOption that sets the metadata that is sent to each node when the connection is initially established. This metadata can be retrieved from the server-side method handlers.

func WithNoConnect

func WithNoConnect() ManagerOption

WithNoConnect returns a ManagerOption which instructs the Manager not to connect to any of its nodes. Mainly used for testing purposes.

func WithNodeList

func WithNodeList(addrsList []string) ManagerOption

WithNodeList returns a ManagerOption containing the provided list of node addresses. With this option, NodeIDs are generated by the Manager.

func WithNodeMap

func WithNodeMap(idMap map[string]uint32) ManagerOption

WithNodeMap returns a ManagerOption containing the provided mapping from node addresses to application-specific IDs.

func WithPerNodeMetadata

func WithPerNodeMetadata(f func(uint32) metadata.MD) ManagerOption

WithPerNodeMetadata returns a ManagerOption that allows you to set metadata for each node individually.

func WithSendBufferSize

func WithSendBufferSize(size uint) ManagerOption

WithSendBufferSize allows for changing the size of the send buffer used by Gorums. A larger buffer might achieve higher throughput for asynchronous calltypes, but at the cost of latency.

func WithTracing

func WithTracing() ManagerOption

WithTracing controls whether to trace quorum calls for this Manager instance using the golang.org/x/net/trace package. Tracing is currently only supported for regular quorum calls.

type MultiSorter

type MultiSorter struct {
	// contains filtered or unexported fields
}

MultiSorter implements the Sort interface, sorting the nodes within.

func OrderedBy

func OrderedBy(less ...lessFunc) *MultiSorter

OrderedBy returns a Sorter that sorts using the less functions, in order. Call its Sort method to sort the data.

func (*MultiSorter) Len

func (ms *MultiSorter) Len() int

Len is part of sort.Interface.

func (*MultiSorter) Less

func (ms *MultiSorter) Less(i, j int) bool

Less is part of sort.Interface. It is implemented by looping along the less functions until it finds a comparison that is either Less or !Less. Note that it can call the less functions twice per call. We could change the functions to return -1, 0, 1 and reduce the number of calls for greater efficiency: an exercise for the reader.

func (*MultiSorter) Sort

func (ms *MultiSorter) Sort(nodes []*Node)

Sort sorts the argument slice according to the less functions passed to OrderedBy.

func (*MultiSorter) Swap

func (ms *MultiSorter) Swap(i, j int)

Swap is part of sort.Interface.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node encapsulates the state of a node on which a remote procedure call can be performed.

func (*Node) Address

func (n *Node) Address() string

Address returns network address of n.

func (*Node) FullString

func (n *Node) FullString() string

FullString returns a more descriptive string representation of n that includes id, network address and latency information.

func (*Node) ID

func (n *Node) ID() uint32

ID returns the ID of n.

func (*Node) LastErr

func (n *Node) LastErr() error

LastErr returns the last error encountered (if any) when invoking a remote procedure call on this node.

func (*Node) Latency

func (n *Node) Latency() time.Duration

Latency returns the latency of the last successful remote procedure call made to this node.

func (*Node) NewView

func (n *Node) NewView(in *QuorumCert) error

func (*Node) Port

func (n *Node) Port() string

Port returns network port of n.

func (*Node) String

func (n *Node) String() string

func (*Node) Vote

func (n *Node) Vote(in *PartialCert) error

type NodeNotFoundError

type NodeNotFoundError uint32

A NodeNotFoundError reports that a specified node could not be found.

func (NodeNotFoundError) Error

func (e NodeNotFoundError) Error() string

type PartialCert

type PartialCert struct {
	Sig  *PartialSig `protobuf:"bytes,1,opt,name=Sig,proto3" json:"Sig,omitempty"`
	Hash []byte      `protobuf:"bytes,2,opt,name=Hash,proto3" json:"Hash,omitempty"`
	// contains filtered or unexported fields
}

func PartialCertToProto

func PartialCertToProto(p *data.PartialCert) *PartialCert

func (*PartialCert) Descriptor deprecated

func (*PartialCert) Descriptor() ([]byte, []int)

Deprecated: Use PartialCert.ProtoReflect.Descriptor instead.

func (*PartialCert) FromProto

func (ppc *PartialCert) FromProto() *data.PartialCert

func (*PartialCert) GetHash

func (x *PartialCert) GetHash() []byte

func (*PartialCert) GetSig

func (x *PartialCert) GetSig() *PartialSig

func (*PartialCert) ProtoMessage

func (*PartialCert) ProtoMessage()

func (*PartialCert) ProtoReflect

func (x *PartialCert) ProtoReflect() protoreflect.Message

func (*PartialCert) Reset

func (x *PartialCert) Reset()

func (*PartialCert) String

func (x *PartialCert) String() string

type PartialSig

type PartialSig struct {
	ReplicaID int32  `protobuf:"varint,1,opt,name=ReplicaID,proto3" json:"ReplicaID,omitempty"`
	R         []byte `protobuf:"bytes,2,opt,name=R,proto3" json:"R,omitempty"`
	S         []byte `protobuf:"bytes,3,opt,name=S,proto3" json:"S,omitempty"`
	// contains filtered or unexported fields
}

func PartialSigToProto

func PartialSigToProto(p *data.PartialSig) *PartialSig

func (*PartialSig) Descriptor deprecated

func (*PartialSig) Descriptor() ([]byte, []int)

Deprecated: Use PartialSig.ProtoReflect.Descriptor instead.

func (*PartialSig) FromProto

func (pps *PartialSig) FromProto() *data.PartialSig

func (*PartialSig) GetR

func (x *PartialSig) GetR() []byte

func (*PartialSig) GetReplicaID

func (x *PartialSig) GetReplicaID() int32

func (*PartialSig) GetS

func (x *PartialSig) GetS() []byte

func (*PartialSig) ProtoMessage

func (*PartialSig) ProtoMessage()

func (*PartialSig) ProtoReflect

func (x *PartialSig) ProtoReflect() protoreflect.Message

func (*PartialSig) Reset

func (x *PartialSig) Reset()

func (*PartialSig) String

func (x *PartialSig) String() string

type QuorumCallError

type QuorumCallError struct {
	Reason     string
	ReplyCount int
	Errors     []GRPCError
}

A QuorumCallError is used to report that a quorum call failed.

func (QuorumCallError) Error

func (e QuorumCallError) Error() string

type QuorumCert

type QuorumCert struct {
	Sigs []*PartialSig `protobuf:"bytes,1,rep,name=Sigs,proto3" json:"Sigs,omitempty"`
	Hash []byte        `protobuf:"bytes,2,opt,name=Hash,proto3" json:"Hash,omitempty"`
	// contains filtered or unexported fields
}

func QuorumCertToProto

func QuorumCertToProto(qc *data.QuorumCert) *QuorumCert

func (*QuorumCert) Descriptor deprecated

func (*QuorumCert) Descriptor() ([]byte, []int)

Deprecated: Use QuorumCert.ProtoReflect.Descriptor instead.

func (*QuorumCert) FromProto

func (pqc *QuorumCert) FromProto() *data.QuorumCert

func (*QuorumCert) GetHash

func (x *QuorumCert) GetHash() []byte

func (*QuorumCert) GetSigs

func (x *QuorumCert) GetSigs() []*PartialSig

func (*QuorumCert) ProtoMessage

func (*QuorumCert) ProtoMessage()

func (*QuorumCert) ProtoReflect

func (x *QuorumCert) ProtoReflect() protoreflect.Message

func (*QuorumCert) Reset

func (x *QuorumCert) Reset()

func (*QuorumCert) String

func (x *QuorumCert) String() string

type QuorumSpec

type QuorumSpec interface {
}

QuorumSpec is the interface of quorum functions for Hotstuff.

type ServerOption

type ServerOption func(*serverOptions)

ServerOption is used to change settings for the GorumsServer

func WithGRPCServerOptions

func WithGRPCServerOptions(opts ...grpc.ServerOption) ServerOption

WithGRPCServerOptions allows to set gRPC options for the server.

func WithServerBufferSize

func WithServerBufferSize(size uint) ServerOption

WithServerBufferSize sets the buffer size for the server. A larger buffer may result in higher throughput at the cost of higher latency.

Jump to

Keyboard shortcuts

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