1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-09 09:35:03 +09:00

coord nodeconf source, nodeconf service updates

This commit is contained in:
Sergey Cherepanov 2023-04-08 17:01:40 +02:00 committed by Mikhail Iudin
parent 18db36a70a
commit 93cd6897d3
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
7 changed files with 414 additions and 85 deletions

View file

@ -21,8 +21,8 @@ type NodeConf interface {
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
// PeerAddresses returns peer addresses by peer id
PeerAddresses(peerId string) (addrs []string, ok bool)
// CHash returns nodes consistent table
CHash() chash.CHash
// Partition returns partition number by spaceId
@ -40,6 +40,7 @@ type nodeConf struct {
chash chash.CHash
allMembers []Node
c Configuration
addrs map[string][]string
}
func (c *nodeConf) Id() string {
@ -82,12 +83,9 @@ func (c *nodeConf) CoordinatorPeers() []string {
return c.coordinatorPeers
}
func (c *nodeConf) Addresses() map[string][]string {
res := make(map[string][]string)
for _, m := range c.allMembers {
res[m.PeerId] = m.Addresses
}
return res
func (c *nodeConf) PeerAddresses(peerId string) (addrs []string, ok bool) {
addrs, ok = c.addrs[peerId]
return
}
func (c *nodeConf) CHash() chash.CHash {