...

Package test

import "github.com/SmartBFT-Go/consensus/test"
Overview
Index

Overview ▾

Index ▾

type App
    func (a *App) AssembleProposal(metadata []byte, requests [][]byte) types.Proposal
    func (a *App) ClearMutateSend(target uint64)
    func (a *App) Connect()
    func (a *App) ConnectTo(target uint64)
    func (a *App) Deliver(proposal types.Proposal, signatures []types.Signature) types.Reconfig
    func (a *App) Disconnect()
    func (a *App) DisconnectFrom(target uint64)
    func (a *App) MutateSend(target uint64, mutating func(uint64, *smartbftprotos.Message))
    func (a *App) Mute()
    func (a *App) RequestID(req []byte) types.RequestInfo
    func (a *App) RequestsFromProposal(proposal types.Proposal) []types.RequestInfo
    func (a *App) Restart()
    func (a *App) Sign([]byte) []byte
    func (a *App) SignProposal(types.Proposal) *types.Signature
    func (a *App) Submit(req Request)
    func (a *App) Sync() types.SyncResponse
    func (a *App) UnMute()
    func (a *App) VerificationSequence() uint64
    func (a *App) VerifyConsenterSig(signature types.Signature, prop types.Proposal) error
    func (a *App) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)
    func (a *App) VerifyRequest(val []byte) (types.RequestInfo, error)
    func (a *App) VerifySignature(signature types.Signature) error
type AppRecord
type Configuration
type FwdMessage
    func (*FwdMessage) Descriptor() ([]byte, []int)
    func (m *FwdMessage) GetPayload() []byte
    func (m *FwdMessage) GetSender() uint64
    func (*FwdMessage) ProtoMessage()
    func (m *FwdMessage) Reset()
    func (m *FwdMessage) String() string
    func (m *FwdMessage) XXX_DiscardUnknown()
    func (m *FwdMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
    func (m *FwdMessage) XXX_Merge(src proto.Message)
    func (m *FwdMessage) XXX_Size() int
    func (m *FwdMessage) XXX_Unmarshal(b []byte) error
type Network
    func (n Network) AddOrUpdateNode(id uint64, h handler, app *App)
    func (n Network) Shutdown()
    func (n Network) StartServe()
    func (n Network) StopServe()
type Node
    func (node *Node) Nodes() []uint64
    func (node *Node) SendConsensus(targetID uint64, m *smartbftprotos.Message)
    func (node *Node) SendTransaction(targetID uint64, request []byte)
type Reconfig
type Request
    func (txn Request) ToBytes() []byte

Package files

network.go reconfig.go test_app.go test_messages.pb.go

type App

App implements all interfaces required by an application using this library

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

func (*App) AssembleProposal

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

AssembleProposal assembles a new proposal from the given requests

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) 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) *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, prop types.Proposal) 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(signature types.Signature) error

VerifySignature verifies a signature

type AppRecord

AppRecord represents a committed batch and metadata

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

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

Network is a map of ids and nodes

type Network map[uint64]*Node

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

Node represents a node in a network

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

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

Request represents a client's request

type Request struct {
    ClientID string
    ID       string
    Reconfig Reconfig
}

func (Request) ToBytes

func (txn Request) ToBytes() []byte

ToBytes returns a byte array representation of the request