1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-10 01:51:11 +09:00

coordinator node type

This commit is contained in:
Sergey Cherepanov 2023-02-23 13:38:58 +03:00
parent 64d9689be5
commit 43e4c121ee
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C
3 changed files with 18 additions and 6 deletions

View file

@ -6,6 +6,8 @@ const (
NodeTypeTree NodeType = "tree"
NodeTypeConsensus NodeType = "consensus"
NodeTypeFile NodeType = "file"
NodeTypeCoordinator NodeType = "coordinator"
)
type configGetter interface {

View file

@ -17,6 +17,8 @@ type Configuration interface {
FilePeers() []string
// ConsensusPeers returns list of consensusnodes
ConsensusPeers() []string
// CoordinatorPeers returns list of coordinator nodes
CoordinatorPeers() []string
// Addresses returns map[peerId][]addr with connection addresses for all known nodes
Addresses() map[string][]string
// CHash returns nodes consistent table
@ -28,12 +30,13 @@ type Configuration interface {
}
type configuration struct {
id string
accountId string
filePeers []string
consensusPeers []string
chash chash.CHash
allMembers []NodeConfig
id string
accountId string
filePeers []string
consensusPeers []string
coordinatorPeers []string
chash chash.CHash
allMembers []NodeConfig
}
func (c *configuration) Id() string {
@ -68,6 +71,10 @@ func (c *configuration) ConsensusPeers() []string {
return c.consensusPeers
}
func (c *configuration) CoordinatorPeers() []string {
return c.coordinatorPeers
}
func (c *configuration) Addresses() map[string][]string {
res := make(map[string][]string)
for _, m := range c.allMembers {

View file

@ -80,6 +80,9 @@ func (s *service) Init(a *app.App) (err error) {
if n.HasType(NodeTypeFile) {
fileConfig.filePeers = append(fileConfig.filePeers, n.PeerId)
}
if n.HasType(NodeTypeCoordinator) {
fileConfig.coordinatorPeers = append(fileConfig.coordinatorPeers, n.PeerId)
}
fileConfig.allMembers = append(fileConfig.allMembers, n)
}
if err = fileConfig.chash.AddMembers(members...); err != nil {