add peer state
This commit is contained in:
parent
9f5e6d6018
commit
73602b6c3d
@ -10,12 +10,24 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// now write a go enum for the state partner with self, blacklist, partner
|
||||||
|
|
||||||
|
type PeerState int
|
||||||
|
|
||||||
|
const (
|
||||||
|
NONE PeerState = iota
|
||||||
|
SELF
|
||||||
|
PARTNER
|
||||||
|
BLACKLIST
|
||||||
|
)
|
||||||
|
|
||||||
// Peer is a struct that represents a peer
|
// Peer is a struct that represents a peer
|
||||||
type Peer struct {
|
type Peer struct {
|
||||||
utils.AbstractObject
|
utils.AbstractObject
|
||||||
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"` // Url is the URL of the peer (base64url)
|
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"` // Url is the URL of the peer (base64url)
|
||||||
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"` // PublicKey is the public key of the peer
|
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"` // PublicKey is the public key of the peer
|
||||||
Services map[string]int `json:"services,omitempty" bson:"services,omitempty"` // Services is the services of the peer
|
Services map[string]int `json:"services,omitempty" bson:"services,omitempty"`
|
||||||
|
State PeerState `json:"state" bson:"state" default:"0"`
|
||||||
FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried
|
FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ func GetMyLocalBsonPeer() (string, map[string]interface{}) {
|
|||||||
"id": "6fd0134c-fefc-427e-94c2-e01365fc5fb0",
|
"id": "6fd0134c-fefc-427e-94c2-e01365fc5fb0",
|
||||||
"name": "local_peer",
|
"name": "local_peer",
|
||||||
},
|
},
|
||||||
|
"state": 1,
|
||||||
"url": "http://localhost",
|
"url": "http://localhost",
|
||||||
"public_key": "public_key_lulz",
|
"public_key": "public_key_lulz",
|
||||||
}
|
}
|
||||||
@ -24,6 +25,7 @@ func GetMyLocalJsonPeer() (string, map[string]interface{}) {
|
|||||||
return "6fd0134c-fefc-427e-94c2-e01365fc5fb0", map[string]interface{}{
|
return "6fd0134c-fefc-427e-94c2-e01365fc5fb0", map[string]interface{}{
|
||||||
"id": "6fd0134c-fefc-427e-94c2-e01365fc5fb0",
|
"id": "6fd0134c-fefc-427e-94c2-e01365fc5fb0",
|
||||||
"name": "local_peer",
|
"name": "local_peer",
|
||||||
|
"state": 1,
|
||||||
"url": "http://localhost",
|
"url": "http://localhost",
|
||||||
"public_key": "public_key_lulz",
|
"public_key": "public_key_lulz",
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user