coordinator node type
This commit is contained in:
parent
aa5566c010
commit
d6737cc547
@ -6,6 +6,8 @@ const (
|
|||||||
NodeTypeTree NodeType = "tree"
|
NodeTypeTree NodeType = "tree"
|
||||||
NodeTypeConsensus NodeType = "consensus"
|
NodeTypeConsensus NodeType = "consensus"
|
||||||
NodeTypeFile NodeType = "file"
|
NodeTypeFile NodeType = "file"
|
||||||
|
|
||||||
|
NodeTypeCoordinator NodeType = "coordinator"
|
||||||
)
|
)
|
||||||
|
|
||||||
type configGetter interface {
|
type configGetter interface {
|
||||||
|
|||||||
@ -17,6 +17,8 @@ type Configuration interface {
|
|||||||
FilePeers() []string
|
FilePeers() []string
|
||||||
// ConsensusPeers returns list of consensusnodes
|
// ConsensusPeers returns list of consensusnodes
|
||||||
ConsensusPeers() []string
|
ConsensusPeers() []string
|
||||||
|
// CoordinatorPeers returns list of coordinator nodes
|
||||||
|
CoordinatorPeers() []string
|
||||||
// Addresses returns map[peerId][]addr with connection addresses for all known nodes
|
// Addresses returns map[peerId][]addr with connection addresses for all known nodes
|
||||||
Addresses() map[string][]string
|
Addresses() map[string][]string
|
||||||
// CHash returns nodes consistent table
|
// CHash returns nodes consistent table
|
||||||
@ -28,12 +30,13 @@ type Configuration interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type configuration struct {
|
type configuration struct {
|
||||||
id string
|
id string
|
||||||
accountId string
|
accountId string
|
||||||
filePeers []string
|
filePeers []string
|
||||||
consensusPeers []string
|
consensusPeers []string
|
||||||
chash chash.CHash
|
coordinatorPeers []string
|
||||||
allMembers []NodeConfig
|
chash chash.CHash
|
||||||
|
allMembers []NodeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *configuration) Id() string {
|
func (c *configuration) Id() string {
|
||||||
@ -68,6 +71,10 @@ func (c *configuration) ConsensusPeers() []string {
|
|||||||
return c.consensusPeers
|
return c.consensusPeers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configuration) CoordinatorPeers() []string {
|
||||||
|
return c.coordinatorPeers
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configuration) Addresses() map[string][]string {
|
func (c *configuration) Addresses() map[string][]string {
|
||||||
res := make(map[string][]string)
|
res := make(map[string][]string)
|
||||||
for _, m := range c.allMembers {
|
for _, m := range c.allMembers {
|
||||||
|
|||||||
@ -80,6 +80,9 @@ func (s *service) Init(a *app.App) (err error) {
|
|||||||
if n.HasType(NodeTypeFile) {
|
if n.HasType(NodeTypeFile) {
|
||||||
fileConfig.filePeers = append(fileConfig.filePeers, n.PeerId)
|
fileConfig.filePeers = append(fileConfig.filePeers, n.PeerId)
|
||||||
}
|
}
|
||||||
|
if n.HasType(NodeTypeCoordinator) {
|
||||||
|
fileConfig.coordinatorPeers = append(fileConfig.coordinatorPeers, n.PeerId)
|
||||||
|
}
|
||||||
fileConfig.allMembers = append(fileConfig.allMembers, n)
|
fileConfig.allMembers = append(fileConfig.allMembers, n)
|
||||||
}
|
}
|
||||||
if err = fileConfig.chash.AddMembers(members...); err != nil {
|
if err = fileConfig.chash.AddMembers(members...); err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user