forked from Consensys/quorum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
31 lines (25 loc) · 890 Bytes
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package raft
type RaftNodeInfo struct {
ClusterSize int `json:"clusterSize"`
Role string `json:"role"`
Address *Address `json:"address"`
PeerAddresses []*Address `json:"peerAddresses"`
RemovedPeerIds []uint16 `json:"removedPeerIds"`
AppliedIndex uint64 `json:"appliedIndex"`
SnapshotIndex uint64 `json:"snapshotIndex"`
}
type PublicRaftAPI struct {
raftService *RaftService
}
func NewPublicRaftAPI(raftService *RaftService) *PublicRaftAPI {
return &PublicRaftAPI{raftService}
}
func (s *PublicRaftAPI) Role() string {
return s.raftService.raftProtocolManager.NodeInfo().Role
}
func (s *PublicRaftAPI) AddPeer(enodeId string) (uint16, error) {
return s.raftService.raftProtocolManager.ProposeNewPeer(enodeId)
}
func (s *PublicRaftAPI) RemovePeer(raftId uint16) {
s.raftService.raftProtocolManager.ProposePeerRemoval(raftId)
}