Peer Evolve
This commit is contained in:
@@ -30,11 +30,11 @@ const (
|
||||
SELF
|
||||
PARTNER
|
||||
BLACKLIST
|
||||
UNKNOWN
|
||||
PENDING
|
||||
)
|
||||
|
||||
func (m PeerRelation) String() string {
|
||||
return [...]string{"NONE", "SELF", "PARTNER", "BLACKLIST"}[m]
|
||||
return [...]string{"NONE", "SELF", "PARTNER", "BLACKLIST", "PENDING"}[m]
|
||||
}
|
||||
|
||||
func (m PeerRelation) EnumIndex() int {
|
||||
@@ -63,15 +63,17 @@ func IsMySelf(peerID string) (bool, string) {
|
||||
type Peer struct {
|
||||
utils.AbstractObject
|
||||
|
||||
PeerID string `json:"peer_id" bson:"peer_id" validate:"required"`
|
||||
Url string `json:"url" bson:"url" validate:"required"` // Url is the URL of the peer (base64url)
|
||||
NATSUrl string `json:"nats_url" bson:"nats_url" validate:"required"`
|
||||
WalletAddress string `json:"wallet_address" bson:"wallet_address" validate:"required"` // WalletAddress is the wallet address of the peer
|
||||
PublicKey string `json:"public_key" bson:"public_key" validate:"required"` // PublicKey is the public key of the peer
|
||||
State PeerState `json:"state" bson:"state" default:"0"`
|
||||
Relation PeerRelation `json:"relation" bson:"state" default:"0"`
|
||||
ServicesState map[string]int `json:"services_state,omitempty" bson:"services_state,omitempty"`
|
||||
FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried
|
||||
Verify bool `json:"verify" bson:"verify"`
|
||||
PartnershipPending *PeerRelation `json:"partnership_pending" bson:"partnership_pending"`
|
||||
PeerID string `json:"peer_id" bson:"peer_id" validate:"required"`
|
||||
Url string `json:"url" bson:"url" validate:"required"` // Url is the URL of the peer (base64url)
|
||||
NATSUrl string `json:"nats_url" bson:"nats_url" validate:"required"`
|
||||
WalletAddress string `json:"wallet_address" bson:"wallet_address" validate:"required"` // WalletAddress is the wallet address of the peer
|
||||
PublicKey string `json:"public_key" bson:"public_key" validate:"required"` // PublicKey is the public key of the peer
|
||||
State PeerState `json:"state" bson:"state" default:"0"`
|
||||
Relation PeerRelation `json:"relation" bson:"state" default:"0"`
|
||||
ServicesState map[string]int `json:"services_state,omitempty" bson:"services_state,omitempty"`
|
||||
FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried
|
||||
}
|
||||
|
||||
func (ao *Peer) VerifyAuth(callName string, request *tools.APIRequest) bool {
|
||||
|
||||
@@ -102,6 +102,8 @@ func (ao *AbstractObject) VerifyAuth(callName string, request *tools.APIRequest)
|
||||
return (ao.AccessMode == Public && callName == "get") || request.Admin || (request != nil && ao.CreatorID == request.PeerID && request.PeerID != "")
|
||||
}
|
||||
|
||||
// TODO : check write per auth
|
||||
|
||||
func (ao *AbstractObject) GetObjectFilters(search string) *dbs.Filters {
|
||||
if search == "*" {
|
||||
search = ""
|
||||
|
||||
Reference in New Issue
Block a user