Documentation ¶
Overview ¶
All traits do not need inner locking, because in the node they are accessed in handlers, and handlers all have a mutex lock so that only one handler is running at a time
Index ¶
- Variables
- func SerPK(pk ed25519.PublicKey) []byte
- func SerSK(sk ed25519.PrivateKey) []byte
- type Commit
- func (*Commit) Descriptor() ([]byte, []int)deprecated
- func (x *Commit) GetDigest() []byte
- func (x *Commit) GetNode() string
- func (x *Commit) GetSeq() int64
- func (x *Commit) GetSig() []byte
- func (x *Commit) GetView() int32
- func (*Commit) ProtoMessage()
- func (x *Commit) ProtoReflect() protoreflect.Message
- func (x *Commit) Reset()
- func (x *Commit) String() string
- type Node
- type NodeAPI
- type NodeCommunicator
- type NodeParams
- type NodePrimaryGetter
- type NodeStateMachine
- type NodeStorage
- type NodeUserPKGetter
- type PrePrepare
- func (*PrePrepare) Descriptor() ([]byte, []int)deprecated
- func (x *PrePrepare) GetDigest() []byte
- func (x *PrePrepare) GetSeq() int64
- func (x *PrePrepare) GetSig() []byte
- func (x *PrePrepare) GetView() int32
- func (*PrePrepare) ProtoMessage()
- func (x *PrePrepare) ProtoReflect() protoreflect.Message
- func (x *PrePrepare) Reset()
- func (x *PrePrepare) String() string
- type Prepare
- func (*Prepare) Descriptor() ([]byte, []int)deprecated
- func (x *Prepare) GetDigest() []byte
- func (x *Prepare) GetNode() string
- func (x *Prepare) GetSeq() int64
- func (x *Prepare) GetSig() []byte
- func (x *Prepare) GetView() int32
- func (*Prepare) ProtoMessage()
- func (x *Prepare) ProtoReflect() protoreflect.Message
- func (x *Prepare) Reset()
- func (x *Prepare) String() string
- type Reply
- func (*Reply) Descriptor() ([]byte, []int)deprecated
- func (x *Reply) GetNode() string
- func (x *Reply) GetResult() []byte
- func (x *Reply) GetSig() []byte
- func (x *Reply) GetTimestamp() int64
- func (x *Reply) GetUser() string
- func (x *Reply) GetView() int32
- func (*Reply) ProtoMessage()
- func (x *Reply) ProtoReflect() protoreflect.Message
- func (x *Reply) Reset()
- func (x *Reply) String() string
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetOp() []byte
- func (x *Request) GetSig() []byte
- func (x *Request) GetTimestamp() int64
- func (x *Request) GetUser() string
- func (*Request) ProtoMessage()
- func (x *Request) ProtoReflect() protoreflect.Message
- func (x *Request) Reset()
- func (x *Request) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidSig = errors.New("sig error: invalid signature")
View Source
var ErrInvalidStorage = errors.New("invalid storage error: value is invalid and not put by the app")
View Source
var ErrNoRequestAfterCommittedLocal = errors.New("request error: no request even after committed-local")
View Source
var ErrTimestampNotNew = errors.New("request timestamp error: not newer than the latest handled one")
View Source
var ErrUnknownNodeID = errors.New("id error: can not use the ID to get the required information of the node")
View Source
var ErrUnknownUser = errors.New("user error: can not get the public key of the user due to unknown user")
View Source
var ErrUnmatchedDigest = errors.New("digest error: the digest of the request is not matched with the digest in the preprepare")
View Source
var ErrUnmatchedPP = errors.New("preprepare error: accepted 2 preprepares and the 2 do not match")
View Source
var ErrUnmatchedView = errors.New("view error: the view is not matched with the current node state")
View Source
var File_msg_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Commit ¶
type Commit struct { Sig []byte `protobuf:"bytes,1,opt,name=sig,proto3" json:"sig,omitempty"` View int32 `protobuf:"varint,2,opt,name=view,proto3" json:"view,omitempty"` Seq int64 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` Digest []byte `protobuf:"bytes,4,opt,name=digest,proto3" json:"digest,omitempty"` Node string `protobuf:"bytes,5,opt,name=node,proto3" json:"node,omitempty"` // contains filtered or unexported fields }
func (*Commit) Descriptor
deprecated
func (*Commit) ProtoMessage ¶
func (*Commit) ProtoMessage()
func (*Commit) ProtoReflect ¶
func (x *Commit) ProtoReflect() protoreflect.Message
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func NewNode ¶
func NewNode(np NodeParams, nc NodeCommunicator, ns NodeStorage, nsm NodeStateMachine, nupg NodeUserPKGetter, npg NodePrimaryGetter) *Node
func (*Node) HandleCommit ¶
func (*Node) HandlePrePrepare ¶
func (*Node) HandlePrepare ¶
func (*Node) HandleRequest ¶
type NodeCommunicator ¶
type NodeCommunicator interface { Unicast(msgB []byte, toNode string, msgType msgType) error // Broadcast should not sends the msg to itself, as that has been done in this library. Broadcast(msgB []byte, fromNode string, msgType msgType) error // BroadcastWithLarge is similar to [Broadcast], but it sends a small msg msgB together with a large msg msgLB, e.g., a preprepare with a request. // If you do not need the optimization, you can combine the two msgs and send them in one time. BroadcastWithLarge(msgB []byte, msgLB []byte, fromNode string, msgType msgType) error // Return can only send reply msg so no msgType is required Return(msgB []byte, toUser string) error }
NodeCommunicator needs to handle stable transmission, e.g., retrying / timeouts
type NodeParams ¶
type NodePrimaryGetter ¶
type NodeStateMachine ¶
type NodeStorage ¶
type NodeStorage interface { Put(key string, val []byte) error // Get returns nil if not found Get(key string) (val []byte, err error) }
NodeStorage key of it use / to separate namespaces
type NodeUserPKGetter ¶
type PrePrepare ¶
type PrePrepare struct { Sig []byte `protobuf:"bytes,1,opt,name=sig,proto3" json:"sig,omitempty"` View int32 `protobuf:"varint,2,opt,name=view,proto3" json:"view,omitempty"` Seq int64 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` Digest []byte `protobuf:"bytes,4,opt,name=digest,proto3" json:"digest,omitempty"` // contains filtered or unexported fields }
func (*PrePrepare) Descriptor
deprecated
func (*PrePrepare) Descriptor() ([]byte, []int)
Deprecated: Use PrePrepare.ProtoReflect.Descriptor instead.
func (*PrePrepare) GetDigest ¶
func (x *PrePrepare) GetDigest() []byte
func (*PrePrepare) GetSeq ¶
func (x *PrePrepare) GetSeq() int64
func (*PrePrepare) GetSig ¶
func (x *PrePrepare) GetSig() []byte
func (*PrePrepare) GetView ¶
func (x *PrePrepare) GetView() int32
func (*PrePrepare) ProtoMessage ¶
func (*PrePrepare) ProtoMessage()
func (*PrePrepare) ProtoReflect ¶
func (x *PrePrepare) ProtoReflect() protoreflect.Message
func (*PrePrepare) Reset ¶
func (x *PrePrepare) Reset()
func (*PrePrepare) String ¶
func (x *PrePrepare) String() string
type Prepare ¶
type Prepare struct { Sig []byte `protobuf:"bytes,1,opt,name=sig,proto3" json:"sig,omitempty"` View int32 `protobuf:"varint,2,opt,name=view,proto3" json:"view,omitempty"` Seq int64 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` Digest []byte `protobuf:"bytes,4,opt,name=digest,proto3" json:"digest,omitempty"` Node string `protobuf:"bytes,5,opt,name=node,proto3" json:"node,omitempty"` // contains filtered or unexported fields }
func (*Prepare) Descriptor
deprecated
func (*Prepare) ProtoMessage ¶
func (*Prepare) ProtoMessage()
func (*Prepare) ProtoReflect ¶
func (x *Prepare) ProtoReflect() protoreflect.Message
type Reply ¶
type Reply struct { Sig []byte `protobuf:"bytes,1,opt,name=sig,proto3" json:"sig,omitempty"` View int32 `protobuf:"varint,2,opt,name=view,proto3" json:"view,omitempty"` Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` User string `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"` Node string `protobuf:"bytes,5,opt,name=node,proto3" json:"node,omitempty"` // result may be large, so Reply may be large too Result []byte `protobuf:"bytes,6,opt,name=result,proto3" json:"result,omitempty"` // contains filtered or unexported fields }
func (*Reply) Descriptor
deprecated
func (*Reply) GetTimestamp ¶
func (*Reply) ProtoMessage ¶
func (*Reply) ProtoMessage()
func (*Reply) ProtoReflect ¶
func (x *Reply) ProtoReflect() protoreflect.Message
type Request ¶
type Request struct { Sig []byte `protobuf:"bytes,1,opt,name=sig,proto3" json:"sig,omitempty"` // op may be large, so Request may be large too Op []byte `protobuf:"bytes,2,opt,name=op,proto3" json:"op,omitempty"` Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` User string `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"` // contains filtered or unexported fields }
func (*Request) Descriptor
deprecated
func (*Request) GetTimestamp ¶
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.