simplebft

package
v0.0.0-...-7491e2d Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canceller

type Canceller interface {
	Cancel()
}

Canceller allows cancelling of a scheduled timer event.

type Receiver

type Receiver interface {
	Receive(msg *sb.Msg, src uint64)
	Request(req []byte)
	Connection(replica uint64)
	GetChainId() string
}

Receiver defines the API that is exposed by SBFT to the system.

type SBFT

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

SBFT is a simplified PBFT implementation.

func New

func New(id uint64, chainID string, support consensus.ConsenterSupport, config *sb.Options, sys System) (*SBFT, error)

New creates a new SBFT instance.

func (*SBFT) Connection

func (s *SBFT) Connection(replica uint64)

Connection is an event from system to notify a new connection with replica. On connection, we send our latest (weak) checkpoint, and we expect to receive one from replica.

func (*SBFT) GetChainId

func (s *SBFT) GetChainId() string

func (*SBFT) Receive

func (s *SBFT) Receive(m *sb.Msg, src uint64)

Receive is the ingress method for SBFT messages.

func (*SBFT) Request

func (s *SBFT) Request(req []byte)

Request proposes a new request to the BFT network.ls

type System

type System interface {
	Send(chainId string, msg *sb.Msg, dest uint64)
	Timer(d time.Duration, f func()) Canceller
	Deliver(chainId string, batch *sb.Batch)
	AddReceiver(chainId string, receiver Receiver)
	Persist(chainId string, key string, data proto.Message)
	Restore(chainId string, key string, out proto.Message) bool
	LastBatch(chainId string) *sb.Batch
	Sign(data []byte) []byte
	CheckSig(data []byte, src uint64, sig []byte) error
	Reconnect(chainId string, replica uint64)
	Validate(chainID string, req *sb.Request) ([][]*sb.Request, bool)
	Cut(chainID string) []*sb.Request
}

System defines the API that needs to be provided for SBFT.

Jump to

Keyboard shortcuts

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