Documentation ¶
Index ¶
- Constants
- func AppendLogEntrySignData(groupId uint64, term uint64, prevIndex uint64, prevTerm uint64) []byte
- func ApproveAppendSignData(res *pb.ApproveAppendResponse) []byte
- func BytesU64(bs []byte, offset int) uint64
- func CommandSignData(group uint64, sender uint64, reqId uint64, data []byte) []byte
- func ComposeKeyPrefix(group uint64, t uint32) []byte
- func EB(b bool) byte
- func ExpectedHonestPeers(group_peers []*pb.Peer) int
- func GenerateKey() ([]byte, []byte, error)
- func GetConfig(kv *badger.KV) (*pb.ServerConfig, error)
- func GetGroupFromKV(groupId uint64, KV *badger.KV) *pb.RaftGroup
- func GetGroupPeersFromKV(group uint64, KV *badger.KV) map[uint64]*pb.Peer
- func HashPublicKey(key *rsa.PublicKey) uint64
- func ItemValue(item *badger.KVItem) *[]byte
- func LogEntryKey(groupId uint64, entryIndex uint64) []byte
- func LogHash(prevHash []byte, index uint64, funcId uint64, args []byte) ([]byte, crypto.Hash)
- func ParsePrivateKey(data []byte) (*rsa.PrivateKey, error)
- func ParsePublicKey(data []byte) (*rsa.PublicKey, error)
- func PublicKeyFromPrivate(key *rsa.PrivateKey) *rsa.PublicKey
- func RandomTimeout(mult float32) int
- func RefreshTimer(meta *RTGroupMeta, mult float32)
- func RequestVoteRequestSignData(req *pb.RequestVoteRequest) []byte
- func RequestVoteResponseSignData(res *pb.RequestVoteResponse) []byte
- func SHA1Hash(data []byte) ([]byte, crypto.Hash)
- func ScanHostedGroups(kv *badger.KV, serverId uint64) map[uint64]*RTGroupMeta
- func U32Bytes(t uint32) []byte
- func U64Bytes(n uint64) []byte
- func VerifySign(publicKey *rsa.PublicKey, signature []byte, data []byte) error
- type BFTRaftServer
- func (s *BFTRaftServer) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
- func (s *BFTRaftServer) AppendEntryToLocal(group *pb.RaftGroup, entry *pb.LogEntry) error
- func (s *BFTRaftServer) ApproveAppend(ctx context.Context, req *pb.AppendEntriesResponse) (*pb.ApproveAppendResponse, error)
- func (s *BFTRaftServer) BecomeCandidate(meta *RTGroupMeta)
- func (s *BFTRaftServer) BecomeFollower(meta *RTGroupMeta, appendEntryReq *pb.AppendEntriesRequest) bool
- func (s *BFTRaftServer) BecomeLeader(meta *RTGroupMeta)
- func (s *BFTRaftServer) CommitGroupLog(groupId uint64, cmd *pb.CommandRequest) *[]byte
- func (s *BFTRaftServer) ExecCommand(ctx context.Context, cmd *pb.CommandRequest) (*pb.CommandResponse, error)
- func (s *BFTRaftServer) GetClient(clientId uint64) *spb.Client
- func (s *BFTRaftServer) GetClientPublicKey(clientId uint64) *rsa.PublicKey
- func (s *BFTRaftServer) GetGroup(groupId uint64) *pb.RaftGroup
- func (s *BFTRaftServer) GetGroupLogLastIndex(groupId uint64) uint64
- func (s *BFTRaftServer) GetLogEntry(groupId uint64, entryIndex uint64) *pb.LogEntry
- func (s *BFTRaftServer) GetNode(nodeId uint64) *pb.Node
- func (s *BFTRaftServer) GetNodePublicKey(nodeId uint64) *rsa.PublicKey
- func (s *BFTRaftServer) GetPeer(group uint64, peer_id uint64) *pb.Peer
- func (s *BFTRaftServer) GroupPeersSlice(groupId uint64) []*pb.Peer
- func (s *BFTRaftServer) GroupServerPeer(groupId uint64) *pb.Peer
- func (s *BFTRaftServer) IncrGetGroupLogLastIndex(groupId uint64) uint64
- func (s *BFTRaftServer) LastEntryHash(group_id uint64) []byte
- func (s *BFTRaftServer) LastLogEntry(group uint64) *pb.LogEntry
- func (s *BFTRaftServer) NodesIterator() NodeIterator
- func (s *BFTRaftServer) PeerApprovedAppend(groupId uint64, logIndex uint64, peer uint64, group_peers []*pb.Peer, ...)
- func (s *BFTRaftServer) PeerUncommittedLogEntries(group *pb.RaftGroup, peer *pb.Peer) ([]*pb.LogEntry, *pb.LogEntry)
- func (s *BFTRaftServer) RegisterServerFunc(group uint64, func_id uint64, fn func(arg []byte) []byte)
- func (s *BFTRaftServer) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
- func (s *BFTRaftServer) ReversedLogIterator(group uint64) LogEntryIterator
- func (s *BFTRaftServer) SaveGroup(group *pb.RaftGroup)
- func (s *BFTRaftServer) SavePeer(peer *pb.Peer)
- func (s *BFTRaftServer) SendFollowersHeartbeat(ctx context.Context, leader_peer_id uint64, group *pb.RaftGroup)
- func (s *BFTRaftServer) SendPeerUncommittedLogEntries(ctx context.Context, group *pb.RaftGroup, peer *pb.Peer)
- func (s *BFTRaftServer) SetLogAppended(groupId uint64, logIndex uint64, isApproved bool)
- func (s *BFTRaftServer) Sign(data []byte) []byte
- func (s *BFTRaftServer) StartTimingWheel()
- func (s *BFTRaftServer) VerifyCommandSign(cmd *spb.CommandRequest) bool
- func (s *BFTRaftServer) WaitLogApproved(groupId uint64, logIndex uint64) bool
- type Client
- type ClientStore
- type ClusterClient
- type ClusterClientStore
- type LogAppendError
- type LogEntryIterator
- type NodeIterator
- type Options
- type RTGroupMeta
Constants ¶
View Source
const ( LEADER = 0 FOLLOWER = 1 CANDIDATE = 2 OBSERVER = 3 )
View Source
const ( LOG_ENTRIES = 0 GROUP_PEERS = 1 GROUP_META = 2 NODES_LIST = 3 GROUP_LAST_IDX = 4 CLIENT = 5 SERVER_CONF = 100 )
View Source
const ( NODE_LIST_GROUP = 1 CLIENT_LIST_GROUP = 2 CONFIG_GROUP = 0 )
View Source
const ( UINT32_LEN = 4 UINT64_LEN = 8 )
View Source
const MAX_TERM_BUMP = 10
Variables ¶
This section is empty.
Functions ¶
func AppendLogEntrySignData ¶
func ApproveAppendSignData ¶
func ApproveAppendSignData(res *pb.ApproveAppendResponse) []byte
func CommandSignData ¶
func ComposeKeyPrefix ¶
func ExpectedHonestPeers ¶
func GenerateKey ¶
func GetGroupPeersFromKV ¶
func HashPublicKey ¶
func LogEntryKey ¶
func ParsePrivateKey ¶
func ParsePrivateKey(data []byte) (*rsa.PrivateKey, error)
func PublicKeyFromPrivate ¶
func PublicKeyFromPrivate(key *rsa.PrivateKey) *rsa.PublicKey
func RandomTimeout ¶
func RefreshTimer ¶
func RefreshTimer(meta *RTGroupMeta, mult float32)
func RequestVoteRequestSignData ¶
func RequestVoteRequestSignData(req *pb.RequestVoteRequest) []byte
func RequestVoteResponseSignData ¶
func RequestVoteResponseSignData(res *pb.RequestVoteResponse) []byte
func ScanHostedGroups ¶
func ScanHostedGroups(kv *badger.KV, serverId uint64) map[uint64]*RTGroupMeta
Types ¶
type BFTRaftServer ¶
type BFTRaftServer struct { Id uint64 Opts Options DB *badger.KV FuncReg map[uint64]map[uint64]func(arg []byte) []byte GroupsOnboard map[uint64]*RTGroupMeta Peers *cache.Cache Groups *cache.Cache Nodes *cache.Cache Clients *cache.Cache GroupAppendedLogs *cache.Cache GroupApprovedLogs *cache.Cache GroupLeaderLiveness *cache.Cache NodePublicKeys *cache.Cache ClientPublicKeys *cache.Cache PrivateKey *rsa.PrivateKey ClusterClients ClusterClientStore ClientRPCs ClientStore // contains filtered or unexported fields }
func (*BFTRaftServer) AppendEntries ¶
func (s *BFTRaftServer) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
func (*BFTRaftServer) AppendEntryToLocal ¶
func (*BFTRaftServer) ApproveAppend ¶
func (s *BFTRaftServer) ApproveAppend(ctx context.Context, req *pb.AppendEntriesResponse) (*pb.ApproveAppendResponse, error)
func (*BFTRaftServer) BecomeCandidate ¶
func (s *BFTRaftServer) BecomeCandidate(meta *RTGroupMeta)
func (*BFTRaftServer) BecomeFollower ¶
func (s *BFTRaftServer) BecomeFollower(meta *RTGroupMeta, appendEntryReq *pb.AppendEntriesRequest) bool
func (*BFTRaftServer) BecomeLeader ¶
func (s *BFTRaftServer) BecomeLeader(meta *RTGroupMeta)
func (*BFTRaftServer) CommitGroupLog ¶
func (s *BFTRaftServer) CommitGroupLog(groupId uint64, cmd *pb.CommandRequest) *[]byte
func (*BFTRaftServer) ExecCommand ¶
func (s *BFTRaftServer) ExecCommand(ctx context.Context, cmd *pb.CommandRequest) (*pb.CommandResponse, error)
func (*BFTRaftServer) GetClientPublicKey ¶
func (s *BFTRaftServer) GetClientPublicKey(clientId uint64) *rsa.PublicKey
func (*BFTRaftServer) GetGroupLogLastIndex ¶
func (s *BFTRaftServer) GetGroupLogLastIndex(groupId uint64) uint64
func (*BFTRaftServer) GetLogEntry ¶
func (s *BFTRaftServer) GetLogEntry(groupId uint64, entryIndex uint64) *pb.LogEntry
func (*BFTRaftServer) GetNodePublicKey ¶
func (s *BFTRaftServer) GetNodePublicKey(nodeId uint64) *rsa.PublicKey
func (*BFTRaftServer) GetPeer ¶
func (s *BFTRaftServer) GetPeer(group uint64, peer_id uint64) *pb.Peer
func (*BFTRaftServer) GroupPeersSlice ¶
func (s *BFTRaftServer) GroupPeersSlice(groupId uint64) []*pb.Peer
func (*BFTRaftServer) GroupServerPeer ¶
func (s *BFTRaftServer) GroupServerPeer(groupId uint64) *pb.Peer
func (*BFTRaftServer) IncrGetGroupLogLastIndex ¶
func (s *BFTRaftServer) IncrGetGroupLogLastIndex(groupId uint64) uint64
func (*BFTRaftServer) LastEntryHash ¶
func (s *BFTRaftServer) LastEntryHash(group_id uint64) []byte
func (*BFTRaftServer) LastLogEntry ¶
func (s *BFTRaftServer) LastLogEntry(group uint64) *pb.LogEntry
func (*BFTRaftServer) NodesIterator ¶
func (s *BFTRaftServer) NodesIterator() NodeIterator
func (*BFTRaftServer) PeerApprovedAppend ¶
func (*BFTRaftServer) PeerUncommittedLogEntries ¶
func (*BFTRaftServer) RegisterServerFunc ¶
func (s *BFTRaftServer) RegisterServerFunc(group uint64, func_id uint64, fn func(arg []byte) []byte)
func (*BFTRaftServer) RequestVote ¶
func (s *BFTRaftServer) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
func (*BFTRaftServer) ReversedLogIterator ¶
func (s *BFTRaftServer) ReversedLogIterator(group uint64) LogEntryIterator
func (*BFTRaftServer) SaveGroup ¶
func (s *BFTRaftServer) SaveGroup(group *pb.RaftGroup)
func (*BFTRaftServer) SavePeer ¶
func (s *BFTRaftServer) SavePeer(peer *pb.Peer)
func (*BFTRaftServer) SendFollowersHeartbeat ¶
func (*BFTRaftServer) SendPeerUncommittedLogEntries ¶
func (*BFTRaftServer) SetLogAppended ¶
func (s *BFTRaftServer) SetLogAppended(groupId uint64, logIndex uint64, isApproved bool)
func (*BFTRaftServer) Sign ¶
func (s *BFTRaftServer) Sign(data []byte) []byte
func (*BFTRaftServer) StartTimingWheel ¶
func (s *BFTRaftServer) StartTimingWheel()
func (*BFTRaftServer) VerifyCommandSign ¶
func (s *BFTRaftServer) VerifyCommandSign(cmd *spb.CommandRequest) bool
func (*BFTRaftServer) WaitLogApproved ¶
func (s *BFTRaftServer) WaitLogApproved(groupId uint64, logIndex uint64) bool
type ClientStore ¶
type ClientStore struct {
// contains filtered or unexported fields
}
func NewClientStore ¶
func NewClientStore() ClientStore
type ClusterClient ¶
type ClusterClient struct {
// contains filtered or unexported fields
}
type ClusterClientStore ¶
type ClusterClientStore struct {
// contains filtered or unexported fields
}
func NewClusterClientStore ¶
func NewClusterClientStore() ClusterClientStore
func (*ClusterClientStore) Get ¶
func (cs *ClusterClientStore) Get(serverAddr string) (*ClusterClient, error)
type LogAppendError ¶
type LogAppendError struct {
// contains filtered or unexported fields
}
func (*LogAppendError) Error ¶
func (e *LogAppendError) Error() string
type LogEntryIterator ¶
type LogEntryIterator struct {
// contains filtered or unexported fields
}
func (*LogEntryIterator) Close ¶
func (liter *LogEntryIterator) Close()
func (*LogEntryIterator) Next ¶
func (liter *LogEntryIterator) Next() *pb.LogEntry
type NodeIterator ¶
type NodeIterator struct {
// contains filtered or unexported fields
}
func (*NodeIterator) Close ¶
func (liter *NodeIterator) Close()
func (*NodeIterator) Next ¶
func (liter *NodeIterator) Next() *pb.Node
Click to show internal directories.
Click to hide internal directories.