adjust self

This commit is contained in:
mr
2026-02-23 14:07:39 +01:00
parent 12c506e9a7
commit 19b0f10e71
5 changed files with 20 additions and 59 deletions

View File

@@ -175,24 +175,24 @@ func GenericRawUpdateOne(set DBObject, id string, a Accessor) (DBObject, int, er
return a.LoadOne(id)
}
func GetMySelf(wfa Accessor) (string, error) {
func GetMySelf(wfa Accessor) (ShallowDBObject, error) {
id, err := GenerateNodeID()
if err != nil {
return "", err
return nil, err
}
datas, _, _ := wfa.Search(nil, id, false)
if len(datas) > 0 {
return datas[0].GetID(), nil
return datas[0], nil
}
return "", errors.New("peer not found")
return nil, errors.New("peer not found")
}
func IsMySelf(peerID string, wfa Accessor) (bool, string) {
id, err := GetMySelf(wfa)
if err != nil {
pp, err := GetMySelf(wfa)
if err != nil || pp == nil {
return false, ""
}
return peerID == id, id
return peerID == pp.GetID(), pp.GetID()
}
func GenerateNodeID() (string, error) {