p2p

package
v0.0.0-...-00b5140 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package P2P represents a peer-to-peer network linked with go-libp2p.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter représente un adaptateur pair à pair.

func New

func New(
	cfg Config,
	per persistenceadapter.Adapter,
	wallets wallet.IWallets,
	logs *zap.Logger,
	evt *event.Event,
	opts ...Option,
) *Adapter

New represent a new peer to peer adapter.

func (*Adapter) Enabled

func (e *Adapter) Enabled() bool

Enabled indicates if the peer-to-peer system is activated.

func (*Adapter) Handle

func (e *Adapter) Handle(err error)

func (*Adapter) HasTarget

func (e *Adapter) HasTarget() bool

HasTarget indicates if a connection target is set.

func (*Adapter) Listen

func (e *Adapter) Listen(stop chan error)

Listen starts listening for peer-to-peer connection.

func (*Adapter) PushMsgForFiles

func (e *Adapter) PushMsgForFiles(stop chan error)

PushMsgForFiles sends a message to retrieve files.

func (*Adapter) SetTarget

func (e *Adapter) SetTarget(target string)

SetTarget sets the connection target.

func (*Adapter) Shutdown

func (e *Adapter) Shutdown()

Shutdown stops the host.

func (*Adapter) Target

func (e *Adapter) Target() string

Target returns the connection target.

type Config

type Config struct {
	Enabled bool `"mapstructure:p2p_enabled"`
	// Parse options from the command line
	// Port ouvre le port auquel nous voulons autoriser les connexions
	Port int `mapstructure:"p2p_port"`
	// secio : sécurisation des flux
	Secio bool `mapstructure:"p2p_secio_enabled"`
	// target nous permet de spécifier l'adresse d'un autre hôte auquel nous voulons nous connecter,
	// ce qui signifie que nous agissons en tant qu'homologue d'un hôte si nous utilisons ce drapeau.
	Target string `mapstructure:"p2p_target"`
	// seed est le paramètre aléatoire facultatif utilisé pour construire notre adresse
	// que d'autres pairs peuvent utiliser pour se connecter à nous
	Seed int64 `mapstructure:"p2p_seed"`

	TimeToCommunicate int `mapstructure:"p2p_time_to_communicate"`
	// token utilisé pour assurer la sécurité de la connexion
	Token string `mapstructure:"p2p_token"`

	ProtocolID string `mapstructure:"p2p_protocol_ID"`

	DiscoveryNamespace string `mapstructure:"p2p_discovery_name"`

	AddressTimer time.Duration `mapstructure:"p2p_address_timer"`
}

type Option

type Option func(e *Adapter)

Option is the type of option passed to the constructor.

func WithXCache

func WithXCache(cfg XCache) Option

WithXCache offers the possibility to add a cache system to the peer-to-peer adapter.

type XCache

type XCache struct {
	Size            int  `config:"cache_size"`
	TTL             int  `config:"cache_ttl"`
	MaxSizeAccepted int  `config:"cache_max_sized_accepted"`
	NegSize         int  `config:"cache_neg_size"`
	NegTTL          int  `config:"cache_neg_tll"`
	Active          bool `config:"cache_active"`
}

Jump to

Keyboard shortcuts

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