backend

package
v0.0.0-...-7cc9995 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package backend implements the networking backend for hotstuff using the Gorums framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPeerIDFromContext

func GetPeerIDFromContext(ctx context.Context, cfg modules.Configuration) (consbench.ID, error)

GetPeerIDFromContext extracts the ID of the peer from the context.

Types

type Config

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

Config holds information about the current configuration of replicas that participate in the protocol, and some information about the local replica. It also provides methods to send messages to the other replicas.

func NewConfig

func NewConfig(creds credentials.TransportCredentials, opts ...gorums.ManagerOption) *Config

NewConfig creates a new configuration.

func (*Config) Close

func (cfg *Config) Close()

Close closes all connections made by this configuration.

func (*Config) Connect

func (cfg *Config) Connect(replicas []ReplicaInfo) (err error)

Connect opens connections to the replicas in the configuration.

func (*Config) Fetch

func (cfg *Config) Fetch(ctx context.Context, hash consbench.Hash) (*consbench.Block, bool)

Fetch requests a block from all the replicas in the configuration

func (*Config) GetRawConfiguration

func (cfg *Config) GetRawConfiguration() gorums.RawConfiguration

GetRawConfiguration returns the underlying gorums RawConfiguration.

func (*Config) InitModule

func (cfg *Config) InitModule(mods *modules.Core)

InitModule initializes the configuration.

func (*Config) Len

func (cfg *Config) Len() int

Len returns the number of replicas in the configuration.

func (*Config) Propose

func (cfg *Config) Propose(proposal consbench.ProposeMsg)

Propose sends the block to all replicas in the configuration

func (*Config) QuorumSize

func (cfg *Config) QuorumSize() int

QuorumSize returns the size of a quorum

func (*Config) Replica

func (cfg *Config) Replica(id consbench.ID) (replica modules.Replica, ok bool)

Replica returns a replica if it is present in the configuration.

func (*Config) Replicas

func (cfg *Config) Replicas() map[consbench.ID]modules.Replica

Replicas returns all of the replicas in the configuration.

func (*Config) SubConfig

func (cfg *Config) SubConfig(ids []consbench.ID) (sub modules.Configuration, err error)

SubConfig returns a subconfiguration containing the replicas specified in the ids slice.

func (*Config) Timeout

func (cfg *Config) Timeout(msg consbench.TimeoutMsg)

Timeout sends the timeout message to all replicas.

type ConnectedEvent

type ConnectedEvent struct{}

ConnectedEvent is sent when the configuration has connected to the other replicas.

type Replica

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

Replica provides methods used by hotstuff to send messages to replicas.

func (*Replica) ID

func (r *Replica) ID() consbench.ID

ID returns the replica's ID.

func (*Replica) Metadata

func (r *Replica) Metadata() map[string]string

Metadata returns the gRPC metadata from this replica's connection.

func (*Replica) NewView

func (r *Replica) NewView(msg consbench.SyncInfo)

NewView sends the quorum certificate to the other replica.

func (*Replica) PublicKey

func (r *Replica) PublicKey() consbench.PublicKey

PublicKey returns the replica's public key.

func (*Replica) Vote

func (r *Replica) Vote(cert consbench.PartialCert)

Vote sends the partial certificate to the other replica.

type ReplicaInfo

type ReplicaInfo struct {
	ID       consbench.ID
	Address  string
	PubKey   consbench.PublicKey
	Location string
}

ReplicaInfo holds information about a replica.

type Server

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

Server is the Server-side of the gorums backend. It is responsible for calling handler methods on the consensus instance.

func NewServer

func NewServer(opts ...ServerOptions) *Server

NewServer creates a new Server.

func (*Server) GetGorumsServer

func (srv *Server) GetGorumsServer() *gorums.Server

GetGorumsServer returns the underlying gorums Server.

func (*Server) InitModule

func (srv *Server) InitModule(mods *modules.Core)

InitModule initializes the Server.

func (*Server) Start

func (srv *Server) Start(addr string) error

Start creates a listener on the configured address and starts the server.

func (*Server) StartOnListener

func (srv *Server) StartOnListener(listener net.Listener)

StartOnListener starts the server with the given listener.

func (*Server) Stop

func (srv *Server) Stop()

Stop stops the server.

type ServerOptions

type ServerOptions func(*backendOptions)

ServerOptions is a function for configuring the Server.

func WithGorumsServerOptions

func WithGorumsServerOptions(opts ...gorums.ServerOption) ServerOptions

WithGorumsServerOptions sets the gorums server options.

func WithLatencyInfo

func WithLatencyInfo(id consbench.ID, locationInfo map[consbench.ID]string) ServerOptions

WithLatencyInfo sets the location of the replica and the latency matrix.

Jump to

Keyboard shortcuts

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