From 43e4c121ee89f592692a9d53839eb3c6c958bceb Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Thu, 23 Feb 2023 13:38:58 +0300 Subject: [PATCH] coordinator node type --- nodeconf/config.go | 2 ++ nodeconf/configuration.go | 19 +++++++++++++------ nodeconf/service.go | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/nodeconf/config.go b/nodeconf/config.go index a1985be2..09aee8dd 100644 --- a/nodeconf/config.go +++ b/nodeconf/config.go @@ -6,6 +6,8 @@ const ( NodeTypeTree NodeType = "tree" NodeTypeConsensus NodeType = "consensus" NodeTypeFile NodeType = "file" + + NodeTypeCoordinator NodeType = "coordinator" ) type configGetter interface { diff --git a/nodeconf/configuration.go b/nodeconf/configuration.go index bc913fd6..121b79fa 100644 --- a/nodeconf/configuration.go +++ b/nodeconf/configuration.go @@ -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 { diff --git a/nodeconf/service.go b/nodeconf/service.go index e78b4a93..6d313004 100644 --- a/nodeconf/service.go +++ b/nodeconf/service.go @@ -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 {