test

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID        uint64
	Delivered chan *AppRecord
	Consensus *consensus.Consensus
	Setup     func()
	Node      *Node
	// contains filtered or unexported fields
}

App implements all interfaces required by an application using this library

func (*App) AssembleProposal

func (a *App) AssembleProposal(metadata []byte, requests [][]byte) types.Proposal

AssembleProposal assembles a new proposal from the given requests

func (*App) AuxiliaryData

func (a *App) AuxiliaryData(msg []byte) []byte

func (*App) ClearMutateSend

func (a *App) ClearMutateSend(target uint64)

ClearMutateSend clears any mutating function called before sending a message to the target node

func (*App) Connect

func (a *App) Connect()

Connect connects the node to the network

func (*App) ConnectTo

func (a *App) ConnectTo(target uint64)

ConnectTo connects the node to a specific node

func (*App) Deliver

func (a *App) Deliver(proposal types.Proposal, signatures []types.Signature) types.Reconfig

Deliver delivers the given proposal

func (*App) Disconnect

func (a *App) Disconnect()

Disconnect disconnects the node from the network

func (*App) DisconnectFrom

func (a *App) DisconnectFrom(target uint64)

DisconnectFrom disconnects the node from a specific node

func (*App) MembershipChange

func (a *App) MembershipChange() bool

func (*App) MutateSend

func (a *App) MutateSend(target uint64, mutating func(uint64, *smartbftprotos.Message))

MutateSend set the mutating function to be called before sending a message to the target node

func (*App) Mute

func (a *App) Mute()

Mute mutes the log

func (*App) RequestID

func (a *App) RequestID(req []byte) types.RequestInfo

RequestID returns info about the given request

func (*App) RequestsFromProposal

func (a *App) RequestsFromProposal(proposal types.Proposal) []types.RequestInfo

RequestsFromProposal returns from the given proposal the included requests' info

func (*App) Restart

func (a *App) Restart()

Restart restarts the node

func (*App) Sign

func (a *App) Sign([]byte) []byte

Sign signs on the given value

func (*App) SignProposal

func (a *App) SignProposal(_ types.Proposal, aux []byte) *types.Signature

SignProposal signs on the given proposal

func (*App) Submit

func (a *App) Submit(req Request)

Submit submits the client request

func (*App) Sync

func (a *App) Sync() types.SyncResponse

Sync synchronizes and returns the latest decision

func (*App) UnMute

func (a *App) UnMute()

UnMute unmutes the log

func (*App) VerificationSequence

func (a *App) VerificationSequence() uint64

VerificationSequence returns the current verification sequence

func (*App) VerifyConsenterSig

func (a *App) VerifyConsenterSig(signature types.Signature, _ types.Proposal) ([]byte, error)

VerifyConsenterSig verifies a nodes signature on the given proposal

func (*App) VerifyProposal

func (a *App) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)

VerifyProposal verifies the given proposal and returns the included requests

func (*App) VerifyRequest

func (a *App) VerifyRequest(val []byte) (types.RequestInfo, error)

VerifyRequest verifies the given request and returns its info

func (*App) VerifySignature

func (a *App) VerifySignature(_ types.Signature) error

VerifySignature verifies a signature

type AppRecord

type AppRecord struct {
	Batch    *batch
	Metadata []byte
}

AppRecord represents a committed batch and metadata

type Configuration

type Configuration struct {
	// SelfID is added by the application
	RequestBatchMaxCount          int64
	RequestBatchMaxBytes          int64
	RequestBatchMaxInterval       time.Duration
	IncomingMessageBufferSize     int64
	RequestPoolSize               int64
	RequestForwardTimeout         time.Duration
	RequestComplainTimeout        time.Duration
	RequestAutoRemoveTimeout      time.Duration
	ViewChangeResendInterval      time.Duration
	ViewChangeTimeout             time.Duration
	LeaderHeartbeatTimeout        time.Duration
	LeaderHeartbeatCount          int64
	NumOfTicksBehindBeforeSyncing int64
	CollectTimeout                time.Duration
	SyncOnStart                   bool
	SpeedUpViewChange             bool
	LeaderRotation                bool
	DecisionsPerLeader            int64
}

type FwdMessage

type FwdMessage struct {
	Sender               uint64   `protobuf:"varint,1,opt,name=sender,proto3" json:"sender,omitempty"`
	Payload              []byte   `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*FwdMessage) Descriptor

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

func (*FwdMessage) GetPayload

func (m *FwdMessage) GetPayload() []byte

func (*FwdMessage) GetSender

func (m *FwdMessage) GetSender() uint64

func (*FwdMessage) ProtoMessage

func (*FwdMessage) ProtoMessage()

func (*FwdMessage) Reset

func (m *FwdMessage) Reset()

func (*FwdMessage) String

func (m *FwdMessage) String() string

func (*FwdMessage) XXX_DiscardUnknown

func (m *FwdMessage) XXX_DiscardUnknown()

func (*FwdMessage) XXX_Marshal

func (m *FwdMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FwdMessage) XXX_Merge

func (m *FwdMessage) XXX_Merge(src proto.Message)

func (*FwdMessage) XXX_Size

func (m *FwdMessage) XXX_Size() int

func (*FwdMessage) XXX_Unmarshal

func (m *FwdMessage) XXX_Unmarshal(b []byte) error

type Network

type Network map[uint64]*Node

Network is a map of ids and nodes

func (Network) AddOrUpdateNode

func (n Network) AddOrUpdateNode(id uint64, h handler, app *App)

AddOrUpdateNode adds or updates a node in the network

func (Network) Shutdown

func (n Network) Shutdown()

Shutdown stops all nodes in the network

func (Network) StartServe

func (n Network) StartServe()

StartServe calls serve on all nodes in the network

func (Network) StopServe

func (n Network) StopServe()

StopServe stops serve for all nodes in the network

type Node

type Node struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Node represents a node in a network

func (*Node) Nodes

func (node *Node) Nodes() []uint64

Nodes returns the ids of all nodes in the network

func (*Node) SendConsensus

func (node *Node) SendConsensus(targetID uint64, m *smartbftprotos.Message)

SendConsensus sends a consensus related message to a target node

func (*Node) SendTransaction

func (node *Node) SendTransaction(targetID uint64, request []byte)

SendTransaction sends a client's request to a target node

type Reconfig

type Reconfig struct {
	InLatestDecision bool
	CurrentNodes     []int64
	CurrentConfig    Configuration
}

type Request

type Request struct {
	ClientID string
	ID       string
	Reconfig Reconfig
}

Request represents a client's request

func (Request) ToBytes

func (txn Request) ToBytes() []byte

ToBytes returns a byte array representation of the request

Jump to

Keyboard shortcuts

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