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 (a *App) AssembleProposal(metadata []byte, requests [][]byte) types.Proposal
AssembleProposal assembles a new proposal from the given requests
func (a *App) ClearMutateSend(target uint64)
ClearMutateSend clears any mutating function called before sending a message to the target node
func (a *App) Connect()
Connect connects the node to the network
func (a *App) ConnectTo(target uint64)
ConnectTo connects the node to a specific node
func (a *App) Deliver(proposal types.Proposal, signatures []types.Signature) types.Reconfig
Deliver delivers the given proposal
func (a *App) Disconnect()
Disconnect disconnects the node from the network
func (a *App) DisconnectFrom(target uint64)
DisconnectFrom disconnects the node from a specific node
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 (a *App) Mute()
Mute mutes the log
func (a *App) RequestID(req []byte) types.RequestInfo
RequestID returns info about the given request
func (a *App) RequestsFromProposal(proposal types.Proposal) []types.RequestInfo
RequestsFromProposal returns from the given proposal the included requests' info
func (a *App) Restart()
Restart restarts the node
func (a *App) Sign([]byte) []byte
Sign signs on the given value
func (a *App) SignProposal(types.Proposal) *types.Signature
SignProposal signs on the given proposal
func (a *App) Submit(req Request)
Submit submits the client request
func (a *App) Sync() types.SyncResponse
Sync synchronizes and returns the latest decision
func (a *App) UnMute()
UnMute unmutes the log
func (a *App) VerificationSequence() uint64
VerificationSequence returns the current verification sequence
func (a *App) VerifyConsenterSig(signature types.Signature, prop types.Proposal) error
VerifyConsenterSig verifies a nodes signature on the given proposal
func (a *App) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)
VerifyProposal verifies the given proposal and returns the included requests
func (a *App) VerifyRequest(val []byte) (types.RequestInfo, error)
VerifyRequest verifies the given request and returns its info
func (a *App) VerifySignature(signature types.Signature) error
VerifySignature verifies a signature
AppRecord represents a committed batch and metadata
type AppRecord struct { Batch *batch Metadata []byte }
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 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() ([]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
Network is a map of ids and nodes
type Network map[uint64]*Node
func (n Network) AddOrUpdateNode(id uint64, h handler, app *App)
AddOrUpdateNode adds or updates a node in the network
func (n Network) Shutdown()
Shutdown stops all nodes in the network
func (n Network) StartServe()
StartServe calls serve on all nodes in the network
func (n Network) StopServe()
StopServe stops serve for all nodes in the network
Node represents a node in a network
type Node struct { sync.RWMutex // contains filtered or unexported fields }
func (node *Node) Nodes() []uint64
Nodes returns the ids of all nodes in the network
func (node *Node) SendConsensus(targetID uint64, m *smartbftprotos.Message)
SendConsensus sends a consensus related message to a target node
func (node *Node) SendTransaction(targetID uint64, request []byte)
SendTransaction sends a client's request to a target node
type Reconfig struct { InLatestDecision bool CurrentNodes []int64 CurrentConfig Configuration }
Request represents a client's request
type Request struct { ClientID string ID string Reconfig Reconfig }
func (txn Request) ToBytes() []byte
ToBytes returns a byte array representation of the request