This commit is contained in:
mr
2026-01-23 07:45:36 +01:00
parent b71b1e741d
commit 0308b4ea10

View File

@@ -2,6 +2,7 @@ package peer
import ( import (
"fmt" "fmt"
"strings"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools" "cloud.o-forge.io/core/oc-lib/tools"
@@ -33,12 +34,23 @@ const (
PENDING_PARTNER PENDING_PARTNER
) )
var path = []string{"unknown", "self", "partner", "blacklist", "pending_parthner"}
func GetPath(str string) int {
for i, p := range path {
if str == p {
return i
}
}
return -1
}
func (m PeerRelation) Path() string { func (m PeerRelation) Path() string {
return [...]string{"unknown", "self", "partner", "blacklist", "pending_parthner"}[m] return path[m]
} }
func (m PeerRelation) String() string { func (m PeerRelation) String() string {
return [...]string{"NONE", "SELF", "PARTNER", "BLACKLIST", "PENDING_PARTNER"}[m] return strings.ToUpper(path[m])
} }
func (m PeerRelation) EnumIndex() int { func (m PeerRelation) EnumIndex() int {