peer

package
v0.0.0-...-c35b06e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccessor

func NewAccessor(request *tools.APIRequest) *peerMongoAccessor

func NewShallowAccessor

func NewShallowAccessor() *peerMongoAccessor

New creates a new instance of the peerMongoAccessor

Types

type Peer

type Peer struct {
	utils.AbstractObject
	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
}

Peer is a struct that represents a peer

func (*Peer) AddExecution

func (ao *Peer) AddExecution(exec PeerExecution)

AddExecution adds an execution to the list of failed executions

func (*Peer) CanDelete

func (r *Peer) CanDelete() bool

func (*Peer) GetAccessor

func (d *Peer) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*Peer) IsMySelf

func (p *Peer) IsMySelf() (bool, string)

IsMySelf checks if the peer is the local peer

func (*Peer) LaunchPeerExecution

func (p *Peer) LaunchPeerExecution(peerID string, dataID string, dt tools.DataType, method tools.METHOD, body interface{}, caller *tools.HTTPCaller) (map[string]interface{}, error)

LaunchPeerExecution launches an execution on a peer

func (*Peer) RemoveExecution

func (ao *Peer) RemoveExecution(exec PeerExecution)

RemoveExecution removes an execution from the list of failed executions

func (*Peer) VerifyAuth

func (ao *Peer) VerifyAuth(request *tools.APIRequest) bool

type PeerCache

type PeerCache struct {
	Executions []*PeerExecution
}

PeerCache is a struct that represents a peer cache

func (*PeerCache) Exec

func (p *PeerCache) Exec(url string, method tools.METHOD, body interface{}, caller tools.HTTPCallerITF) (map[string]interface{}, error)

exec executes the method on the peer

func (*PeerCache) LaunchPeerExecution

func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string,
	dt tools.DataType, method tools.METHOD, body interface{}, caller tools.HTTPCallerITF) (map[string]interface{}, error)

LaunchPeerExecution launches an execution on a peer The method contacts the path described by : peer.Url + datatype path (from enums) + replacement of id by dataID

type PeerExecution

type PeerExecution struct {
	Method   string      `json:"method" bson:"method"`
	Url      string      `json:"url" bson:"url"`
	Body     interface{} `json:"body" bson:"body"`
	DataType int         `json:"data_type" bson:"data_type"`
	DataID   string      `json:"data_id" bson:"data_id"`
}

* PeerExecution is a struct that represents an execution on a peer * it defines the execution data

type PeerState

type PeerState int
const (
	NONE PeerState = iota
	SELF
	PARTNER
	BLACKLIST
)

func (PeerState) EnumIndex

func (m PeerState) EnumIndex() int

func (PeerState) String

func (m PeerState) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL