massive draft for payment process (UNCOMPLETE)
This commit is contained in:
@@ -29,10 +29,11 @@ func (m PeerState) EnumIndex() int {
|
||||
// Peer is a struct that represents a peer
|
||||
type Peer struct {
|
||||
utils.AbstractObject
|
||||
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required"` // 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
|
||||
Services map[string]int `json:"services,omitempty" bson:"services,omitempty"`
|
||||
Url string `json:"url" bson:"url" validate:"required"` // Url is the URL of the peer (base64url)
|
||||
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"`
|
||||
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
|
||||
}
|
||||
|
||||
@@ -62,13 +63,13 @@ func (ao *Peer) RemoveExecution(exec PeerExecution) {
|
||||
}
|
||||
|
||||
// IsMySelf checks if the peer is the local peer
|
||||
func (ao *Peer) IsMySelf() (bool, string) {
|
||||
d, code, err := New(tools.PEER, "", "", nil, nil).Search(nil, SELF.String())
|
||||
func (p *Peer) IsMySelf() (bool, string) {
|
||||
d, code, err := NewAccessor(nil).Search(nil, SELF.String(), p.IsDraft)
|
||||
if code != 200 || err != nil || len(d) == 0 {
|
||||
return false, ""
|
||||
}
|
||||
id := d[0].GetID()
|
||||
return ao.UUID == id, id
|
||||
return p.UUID == id, id
|
||||
}
|
||||
|
||||
// LaunchPeerExecution launches an execution on a peer
|
||||
@@ -76,11 +77,11 @@ func (p *Peer) LaunchPeerExecution(peerID string, dataID string, dt tools.DataTy
|
||||
p.UUID = peerID
|
||||
return cache.LaunchPeerExecution(peerID, dataID, dt, method, body, caller) // Launch the execution on the peer through the cache
|
||||
}
|
||||
func (d *Peer) GetAccessor(username string, peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New(tools.PEER, username, peerID, groups, caller) // Create a new instance of the accessor
|
||||
func (d *Peer) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
data := NewAccessor(request) // Create a new instance of the accessor
|
||||
return data
|
||||
}
|
||||
|
||||
func (d *Peer) VerifyAuth(username string, peerID string, groups []string) bool {
|
||||
return true
|
||||
func (r *Peer) CanDelete() bool {
|
||||
return false // only draft order can be deleted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user