fix decode node types
This commit is contained in:
parent
cc24e38081
commit
7348f39eff
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"github.com/anytypeio/any-sync/app"
|
"github.com/anytypeio/any-sync/app"
|
||||||
"github.com/anytypeio/any-sync/coordinator/coordinatorclient"
|
"github.com/anytypeio/any-sync/coordinator/coordinatorclient"
|
||||||
|
"github.com/anytypeio/any-sync/coordinator/coordinatorproto"
|
||||||
"github.com/anytypeio/any-sync/nodeconf"
|
"github.com/anytypeio/any-sync/nodeconf"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -41,9 +42,16 @@ func (n *nodeConfSource) GetLast(ctx context.Context, currentId string) (c nodec
|
|||||||
}
|
}
|
||||||
nodes := make([]nodeconf.Node, len(res.Nodes))
|
nodes := make([]nodeconf.Node, len(res.Nodes))
|
||||||
for i, node := range res.Nodes {
|
for i, node := range res.Nodes {
|
||||||
types := make([]nodeconf.NodeType, len(node.Types))
|
types := make([]nodeconf.NodeType, 0, len(node.Types))
|
||||||
for j, nt := range node.Types {
|
for _, nt := range node.Types {
|
||||||
types[j] = nodeconf.NodeType(nt)
|
switch nt {
|
||||||
|
case coordinatorproto.NodeType_FileAPI:
|
||||||
|
types = append(types, nodeconf.NodeTypeFile)
|
||||||
|
case coordinatorproto.NodeType_CoordinatorAPI:
|
||||||
|
types = append(types, nodeconf.NodeTypeCoordinator)
|
||||||
|
case coordinatorproto.NodeType_TreeAPI:
|
||||||
|
types = append(types, nodeconf.NodeTypeTree)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nodes[i] = nodeconf.Node{
|
nodes[i] = nodeconf.Node{
|
||||||
PeerId: node.PeerId,
|
PeerId: node.PeerId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user