Documentation ¶
Index ¶
- Constants
- func AppendLogEntrySignData(groupId uint64, term uint64, prevIndex uint64, prevTerm uint64) []byte
- func ApproveAppendSignData(res *pb.ApproveAppendResponse) []byte
- func ComposeKeyPrefix(group uint64, t uint32) []byte
- func EB(b bool) byte
- func GetConfig(kv *badger.DB) (*pb.ServerConfig, error)
- func GetGroupFromKV(txn *badger.Txn, groupId uint64) *pb.RaftGroup
- func GetGroupPeersFromKV(txn *badger.Txn, group uint64) map[uint64]*pb.Peer
- func GetMembersSignData(members []*pb.GroupMember) []byte
- func InitDatabase(dbPath string)
- func InvitationSignature(inv *pb.GroupInvitation) []byte
- func ItemValue(item *badger.Item) *[]byte
- func LogEntryFromKVItem(item *badger.Item) *pb.LogEntry
- func LogEntryKey(groupId uint64, entryIndex uint64) []byte
- func RandomTimeout(mult float32) int
- func RequestVoteRequestSignData(req *pb.RequestVoteRequest) []byte
- func RequestVoteResponseSignData(res *pb.RequestVoteResponse) []byte
- type BFTRaftServer
- func (s *BFTRaftServer) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
- func (s *BFTRaftServer) ApproveAppend(ctx context.Context, req *pb.AppendEntriesResponse) (*pb.ApproveAppendResponse, error)
- func (s *BFTRaftServer) ColdStart()
- func (s *BFTRaftServer) ExecCommand(ctx context.Context, cmd *pb.CommandRequest) (*pb.CommandResponse, error)
- func (s *BFTRaftServer) GetGroup(txn *badger.Txn, groupId uint64) *pb.RaftGroup
- func (s *BFTRaftServer) GetGroupContent(ctx context.Context, req *pb.GroupId) (*pb.RaftGroup, error)
- func (s *BFTRaftServer) GetGroupHosts(txn *badger.Txn, groupId uint64) []*pb.Host
- func (s *BFTRaftServer) GetGroupHostsNTXN(groupId uint64) []*pb.Host
- func (s *BFTRaftServer) GetGroupLeader(ctx context.Context, req *pb.GroupId) (*pb.GroupLeader, error)
- func (s *BFTRaftServer) GetGroupNTXN(groupId uint64) *pb.RaftGroup
- func (s *BFTRaftServer) GetHost(txn *badger.Txn, nodeId uint64) *pb.Host
- func (s *BFTRaftServer) GetHostNTXN(nodeId uint64) *pb.Host
- func (s *BFTRaftServer) GetHostPublicKey(nodeId uint64) *rsa.PublicKey
- func (s *BFTRaftServer) GetOnboardGroup(id uint64) *RTGroup
- func (s *BFTRaftServer) GroupHosts(ctx context.Context, request *pb.GroupId) (*pb.GroupNodesResponse, error)
- func (s *BFTRaftServer) GroupLeader(groupId uint64) *pb.GroupLeader
- func (s *BFTRaftServer) GroupMembers(ctx context.Context, req *pb.GroupId) (*pb.GroupMembersResponse, error)
- func (s *BFTRaftServer) NewGroup(group *pb.RaftGroup) error
- func (s *BFTRaftServer) NodeJoin(groupId uint64) error
- func (s *BFTRaftServer) PeerApprovedAppend(groupId uint64, logIndex uint64, peer uint64, group_peers []*pb.Peer, ...)
- func (s *BFTRaftServer) PullGroupLogs(ctx context.Context, req *pb.PullGroupLogsResuest) (*pb.LogEntries, error)
- func (s *BFTRaftServer) RegHost() error
- func (s *BFTRaftServer) RegisterMembershipCommands()
- func (s *BFTRaftServer) RegisterRaftFunc(func_id uint64, fn func(arg *[]byte, entry *pb.LogEntry) []byte)
- func (s *BFTRaftServer) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
- func (s *BFTRaftServer) SMNewClient(arg *[]byte, entry *pb.LogEntry) []byte
- func (s *BFTRaftServer) SMNewGroup(arg *[]byte, entry *pb.LogEntry) []byte
- func (s *BFTRaftServer) SMNodeJoin(arg *[]byte, entry *pb.LogEntry) []byte
- func (s *BFTRaftServer) SMRegHost(arg *[]byte, entry *pb.LogEntry) []byte
- func (s *BFTRaftServer) SaveGroup(txn *badger.Txn, group *pb.RaftGroup) error
- func (s *BFTRaftServer) SaveGroupNTXN(group *pb.RaftGroup) error
- func (s *BFTRaftServer) SaveHost(txn *badger.Txn, node *pb.Host) error
- func (s *BFTRaftServer) SaveHostNTXN(node *pb.Host) error
- func (s *BFTRaftServer) SavePeer(txn *badger.Txn, peer *pb.Peer) error
- func (s *BFTRaftServer) ScanHostedGroups(serverId uint64) map[uint64]*RTGroup
- func (s *BFTRaftServer) SendGroupInvitation(ctx context.Context, inv *pb.GroupInvitation) (*pb.Nothing, error)
- func (s *BFTRaftServer) SetOnboardGroup(meta *RTGroup)
- func (s *BFTRaftServer) Sign(data []byte) []byte
- func (s *BFTRaftServer) StartServer() error
- func (s *BFTRaftServer) SyncAlphaGroup()
- func (s *BFTRaftServer) VerifyCommandSign(cmd *pb.CommandRequest) bool
- type Client
- type ClientStore
- type FileConfig
- type LogEntryIterator
- type NodeIterator
- type Options
- type RTGroup
- func (m *RTGroup) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
- func (m *RTGroup) AppendEntryToLocal(txn *badger.Txn, entry *pb.LogEntry) error
- func (m *RTGroup) ApproveAppend(ctx context.Context, req *pb.AppendEntriesResponse) (*pb.ApproveAppendResponse, error)
- func (m *RTGroup) BecomeCandidate()
- func (m *RTGroup) BecomeFollower(appendEntryReq *pb.AppendEntriesRequest) bool
- func (m *RTGroup) BecomeLeader()
- func (m *RTGroup) CommitGroupLog(entry *pb.LogEntry) *[]byte
- func (m *RTGroup) ExpectedHonestPeers() int
- func (m *RTGroup) GetLogEntry(txn *badger.Txn, entryIndex uint64) *pb.LogEntry
- func (m *RTGroup) LastEntryHash(txn *badger.Txn) []byte
- func (m *RTGroup) LastEntryHashNTXN() []byte
- func (m *RTGroup) LastEntryIndex(txn *badger.Txn) uint64
- func (m *RTGroup) LastEntryIndexNTXN() uint64
- func (m *RTGroup) LastLogEntry(txn *badger.Txn) *pb.LogEntry
- func (m *RTGroup) LastLogEntryNTXN() *pb.LogEntry
- func (m *RTGroup) OnboardGroupPeersSlice() []*pb.Peer
- func (m *RTGroup) PeerUncommittedLogEntries(peer *pb.Peer) ([]*pb.LogEntry, *pb.LogEntry)
- func (m *RTGroup) PullAndCommitGroupLogs()
- func (m *RTGroup) RPCGroupMembers(ctx context.Context, req *pb.GroupId) (*pb.GroupMembersResponse, error)
- func (m *RTGroup) RefreshTimer(mult float32)
- func (m *RTGroup) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
- func (m *RTGroup) ResetTerm(term uint64)
- func (m *RTGroup) ReversedLogIterator(txn *badger.Txn) LogEntryIterator
- func (m *RTGroup) SendFollowersHeartbeat(ctx context.Context)
- func (m *RTGroup) SetLogAppended(groupId uint64, logIndex uint64, isApproved bool)
- func (m *RTGroup) StartTimeWheel()
- func (m *RTGroup) WaitLogApproved(logIndex uint64) bool
Constants ¶
View Source
const ( LEADER = 0 FOLLOWER = 1 CANDIDATE = 2 OBSERVER = 3 )
View Source
const ( NODE_JOIN = 0 REG_NODE = 1 NEW_CLIENT = 2 NEW_GROUP = 3 )
View Source
const ( LOG_ENTRIES = 0 GROUP_PEERS = 1 GROUP_META = 2 HOST_LIST = 3 GROUP_LAST_IDX = 4 SERVER_CONF = 100 )
View Source
const ( HOST_LIST_GROUP = 1 CONFIG_GROUP = 0 )
Variables ¶
This section is empty.
Functions ¶
func AppendLogEntrySignData ¶
func ApproveAppendSignData ¶
func ApproveAppendSignData(res *pb.ApproveAppendResponse) []byte
func ComposeKeyPrefix ¶
func GetGroupPeersFromKV ¶
func GetMembersSignData ¶
func GetMembersSignData(members []*pb.GroupMember) []byte
func InitDatabase ¶
func InitDatabase(dbPath string)
func InvitationSignature ¶
func InvitationSignature(inv *pb.GroupInvitation) []byte
func LogEntryKey ¶
func RandomTimeout ¶
func RequestVoteRequestSignData ¶
func RequestVoteRequestSignData(req *pb.RequestVoteRequest) []byte
func RequestVoteResponseSignData ¶
func RequestVoteResponseSignData(res *pb.RequestVoteResponse) []byte
Types ¶
type BFTRaftServer ¶
type BFTRaftServer struct { Id uint64 Opts Options DB *badger.DB // first 10 is reserved for the alpha group FuncReg map[uint64]func(arg *[]byte, entry *pb.LogEntry) []byte GroupsOnboard cmap.ConcurrentMap GroupInvitations map[uint64]chan *pb.GroupInvitation PendingNewGroups map[uint64]chan error Groups *cache.Cache Hosts *cache.Cache NodePublicKeys *cache.Cache ClientPublicKeys *cache.Cache Client *client.BFTRaftClient PrivateKey *rsa.PrivateKey ClientRPCs ClientStore // contains filtered or unexported fields }
func GetServer ¶
func GetServer(serverOpts Options) (*BFTRaftServer, error)
func (*BFTRaftServer) AppendEntries ¶
func (s *BFTRaftServer) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
func (*BFTRaftServer) ApproveAppend ¶
func (s *BFTRaftServer) ApproveAppend(ctx context.Context, req *pb.AppendEntriesResponse) (*pb.ApproveAppendResponse, error)
func (*BFTRaftServer) ColdStart ¶
func (s *BFTRaftServer) ColdStart()
func (*BFTRaftServer) ExecCommand ¶
func (s *BFTRaftServer) ExecCommand(ctx context.Context, cmd *pb.CommandRequest) (*pb.CommandResponse, error)
func (*BFTRaftServer) GetGroupContent ¶
func (*BFTRaftServer) GetGroupHosts ¶
func (*BFTRaftServer) GetGroupHostsNTXN ¶
func (s *BFTRaftServer) GetGroupHostsNTXN(groupId uint64) []*pb.Host
func (*BFTRaftServer) GetGroupLeader ¶
func (s *BFTRaftServer) GetGroupLeader(ctx context.Context, req *pb.GroupId) (*pb.GroupLeader, error)
func (*BFTRaftServer) GetGroupNTXN ¶
func (s *BFTRaftServer) GetGroupNTXN(groupId uint64) *pb.RaftGroup
func (*BFTRaftServer) GetHostNTXN ¶
func (s *BFTRaftServer) GetHostNTXN(nodeId uint64) *pb.Host
func (*BFTRaftServer) GetHostPublicKey ¶
func (s *BFTRaftServer) GetHostPublicKey(nodeId uint64) *rsa.PublicKey
func (*BFTRaftServer) GetOnboardGroup ¶
func (s *BFTRaftServer) GetOnboardGroup(id uint64) *RTGroup
func (*BFTRaftServer) GroupHosts ¶
func (s *BFTRaftServer) GroupHosts(ctx context.Context, request *pb.GroupId) (*pb.GroupNodesResponse, error)
func (*BFTRaftServer) GroupLeader ¶
func (s *BFTRaftServer) GroupLeader(groupId uint64) *pb.GroupLeader
func (*BFTRaftServer) GroupMembers ¶
func (s *BFTRaftServer) GroupMembers(ctx context.Context, req *pb.GroupId) (*pb.GroupMembersResponse, error)
this function should be called only on group members
func (*BFTRaftServer) NodeJoin ¶
func (s *BFTRaftServer) NodeJoin(groupId uint64) error
func (*BFTRaftServer) PeerApprovedAppend ¶
func (*BFTRaftServer) PullGroupLogs ¶
func (s *BFTRaftServer) PullGroupLogs(ctx context.Context, req *pb.PullGroupLogsResuest) (*pb.LogEntries, error)
TODO: Signature
func (*BFTRaftServer) RegHost ¶
func (s *BFTRaftServer) RegHost() error
func (*BFTRaftServer) RegisterMembershipCommands ¶
func (s *BFTRaftServer) RegisterMembershipCommands()
func (*BFTRaftServer) RegisterRaftFunc ¶
func (*BFTRaftServer) RequestVote ¶
func (s *BFTRaftServer) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
func (*BFTRaftServer) SMNewClient ¶
func (s *BFTRaftServer) SMNewClient(arg *[]byte, entry *pb.LogEntry) []byte
func (*BFTRaftServer) SMNewGroup ¶
func (s *BFTRaftServer) SMNewGroup(arg *[]byte, entry *pb.LogEntry) []byte
func (*BFTRaftServer) SMNodeJoin ¶
func (s *BFTRaftServer) SMNodeJoin(arg *[]byte, entry *pb.LogEntry) []byte
func (*BFTRaftServer) SMRegHost ¶
func (s *BFTRaftServer) SMRegHost(arg *[]byte, entry *pb.LogEntry) []byte
Register a node into the network The node may be new or it was rejoined with new address
func (*BFTRaftServer) SaveGroupNTXN ¶
func (s *BFTRaftServer) SaveGroupNTXN(group *pb.RaftGroup) error
func (*BFTRaftServer) SaveHostNTXN ¶
func (s *BFTRaftServer) SaveHostNTXN(node *pb.Host) error
func (*BFTRaftServer) ScanHostedGroups ¶
func (s *BFTRaftServer) ScanHostedGroups(serverId uint64) map[uint64]*RTGroup
func (*BFTRaftServer) SendGroupInvitation ¶
func (s *BFTRaftServer) SendGroupInvitation(ctx context.Context, inv *pb.GroupInvitation) (*pb.Nothing, error)
func (*BFTRaftServer) SetOnboardGroup ¶
func (s *BFTRaftServer) SetOnboardGroup(meta *RTGroup)
func (*BFTRaftServer) Sign ¶
func (s *BFTRaftServer) Sign(data []byte) []byte
func (*BFTRaftServer) StartServer ¶
func (s *BFTRaftServer) StartServer() error
func (*BFTRaftServer) SyncAlphaGroup ¶
func (s *BFTRaftServer) SyncAlphaGroup()
func (*BFTRaftServer) VerifyCommandSign ¶
func (s *BFTRaftServer) VerifyCommandSign(cmd *pb.CommandRequest) bool
type ClientStore ¶
type ClientStore struct {
// contains filtered or unexported fields
}
func NewClientStore ¶
func NewClientStore() ClientStore
type FileConfig ¶
func ReadConfigFile ¶
func ReadConfigFile(path string) FileConfig
type LogEntryIterator ¶
type LogEntryIterator struct {
// contains filtered or unexported fields
}
func (*LogEntryIterator) Close ¶
func (liter *LogEntryIterator) Close()
func (*LogEntryIterator) Current ¶
func (liter *LogEntryIterator) Current() *pb.LogEntry
func (*LogEntryIterator) Next ¶
func (liter *LogEntryIterator) Next() *pb.LogEntry
type NodeIterator ¶
type NodeIterator struct {
// contains filtered or unexported fields
}
type RTGroup ¶
type RTGroup struct { Server *BFTRaftServer Leader uint64 LastVotedTo uint64 LastVotedTerm uint64 GroupPeers map[uint64]*pb.Peer Group *pb.RaftGroup Timeout time.Time Role int Votes []*pb.RequestVoteResponse SendVotesForPeers map[uint64]bool // key is peer id IsBusy *abool.AtomicBool Lock recmutex.RecursiveMutex VoteLock sync.Mutex }
func NewRTGroup ¶
func (*RTGroup) AppendEntries ¶
func (m *RTGroup) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
func (*RTGroup) AppendEntryToLocal ¶
func (*RTGroup) ApproveAppend ¶
func (m *RTGroup) ApproveAppend(ctx context.Context, req *pb.AppendEntriesResponse) (*pb.ApproveAppendResponse, error)
func (*RTGroup) BecomeCandidate ¶
func (m *RTGroup) BecomeCandidate()
func (*RTGroup) BecomeFollower ¶
func (m *RTGroup) BecomeFollower(appendEntryReq *pb.AppendEntriesRequest) bool
func (*RTGroup) BecomeLeader ¶
func (m *RTGroup) BecomeLeader()
func (*RTGroup) ExpectedHonestPeers ¶
func (*RTGroup) GetLogEntry ¶
func (*RTGroup) LastEntryHashNTXN ¶
func (*RTGroup) LastEntryIndexNTXN ¶
func (*RTGroup) LastLogEntryNTXN ¶
func (*RTGroup) OnboardGroupPeersSlice ¶
func (*RTGroup) PeerUncommittedLogEntries ¶
func (*RTGroup) PullAndCommitGroupLogs ¶
func (m *RTGroup) PullAndCommitGroupLogs()
func (*RTGroup) RPCGroupMembers ¶
func (*RTGroup) RefreshTimer ¶
func (*RTGroup) RequestVote ¶
func (m *RTGroup) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
func (*RTGroup) ReversedLogIterator ¶
func (m *RTGroup) ReversedLogIterator(txn *badger.Txn) LogEntryIterator
func (*RTGroup) SendFollowersHeartbeat ¶
func (*RTGroup) SetLogAppended ¶
func (*RTGroup) StartTimeWheel ¶
func (m *RTGroup) StartTimeWheel()
func (*RTGroup) WaitLogApproved ¶
Click to show internal directories.
Click to hide internal directories.