peers logic

This commit is contained in:
mr
2024-08-13 14:33:26 +02:00
parent 4911e32ec2
commit 2d9b4587ac
6 changed files with 180 additions and 99 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/static"
"cloud.o-forge.io/core/oc-lib/tools"
"github.com/google/uuid"
)
@@ -14,6 +15,15 @@ type Peer struct {
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"`
}
func (ao *Peer) IsMySelf() bool {
id, _ := static.GetMyLocalJsonPeer()
return ao.UUID == id
}
func (p *Peer) LaunchPeerExecution(peerID string, dataID string, url string, dt utils.DataType, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) {
return (&PeerCache{}).LaunchPeerExecution(peerID, dataID, url, dt, method, body, caller)
}
func (ao *Peer) GetID() string {
return ao.UUID
}