node

package
v0.8.97 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0, AGPL-3.0-or-later, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DistributedHashTableDiscoverer added in v0.5.80

type DistributedHashTableDiscoverer interface {
	FindProvidersAsync(ctx context.Context, key warpnet.WarpCID, count int) (ch <-chan warpnet.WarpAddrInfo)
	ClosestPeers() []warpnet.WarpPeerID
	Close()
}

type ModeratorNode

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

func NewModeratorNode

func NewModeratorNode(
	ctx context.Context,
	privKey ed25519.PrivateKey,
	psk security.PSK,
	ownNodeId warpnet.WarpPeerID,
	ratings PeersRatings,
) (_ *ModeratorNode, err error)

func (*ModeratorNode) ClosestPeers added in v0.5.21

func (mn *ModeratorNode) ClosestPeers() []warpnet.WarpPeerID

func (*ModeratorNode) GenericStream

func (mn *ModeratorNode) GenericStream(nodeIdStr string, path stream.WarpRoute, data any) (_ []byte, err error)

func (*ModeratorNode) ID added in v0.5.21

func (mn *ModeratorNode) ID() warpnet.WarpPeerID

func (*ModeratorNode) Node

func (mn *ModeratorNode) Node() warpnet.P2PNode

func (*ModeratorNode) NodeInfo

func (mn *ModeratorNode) NodeInfo() warpnet.NodeInfo

func (*ModeratorNode) SelfStream

func (mn *ModeratorNode) SelfStream(_, _ warpnet.WarpPeerID, _ stream.WarpRoute, _ any) (_ []byte, err error)

func (*ModeratorNode) SetStreamHandlers added in v0.8.77

func (mn *ModeratorNode) SetStreamHandlers(handlers ...warpnet.WarpStreamHandler)

SetStreamHandlers registers additional routes after the node is up. The moderator uses it for routes whose handler needs the engine, which only exists once the moderator itself is running.

func (*ModeratorNode) Start

func (mn *ModeratorNode) Start() (err error)

func (*ModeratorNode) StartRating added in v0.8.77

func (mn *ModeratorNode) StartRating(gossip broadcast.GossipPubSuber, audit <-chan warpnet.PeerEvent) error

StartRating rates the peers this node can judge. The process starts it: the records ride the pubsub, and a moderator's standing comes from the audit, neither of which the node owns.

func (*ModeratorNode) Stop

func (mn *ModeratorNode) Stop()

type PeerRater added in v0.8.77

type PeerRater interface {
	Listen(sources ...<-chan warpnet.PeerEvent)
	View(peerID warpnet.WarpPeerID) (domain.NodeRating, error)
	Own() (domain.NodeRating, error)
	Close() error
}

PeerRater listens to what the modules saw the peers do and rates them.

type PeersRatings added in v0.8.77

type PeersRatings interface {
	Rate(peerID warpnet.WarpPeerID, tier rating.Tier)
	ConnTag(peerID warpnet.WarpPeerID) int
	GossipScore(peerID warpnet.WarpPeerID) float64
	RateMultiplier(peerID warpnet.WarpPeerID) float64
	IsAllowedInDHT(peerID warpnet.WarpPeerID) bool
}

PeersRatings is how this node rates its peers: the engine writes it, and this node's modules read what follows from it.

type RatingProvider added in v0.8.77

type RatingProvider interface {
	Get(ctx context.Context, key ds.Key) ([]byte, error)
	Has(ctx context.Context, key ds.Key) (bool, error)
	GetSize(ctx context.Context, key ds.Key) (int, error)
	Query(ctx context.Context, q ds.Query) (ds.Results, error)
	Put(ctx context.Context, key ds.Key, value []byte) error
	Delete(ctx context.Context, key ds.Key) error
	Sync(ctx context.Context, prefix ds.Key) error
	Close() error
}

RatingProvider is the local storage the rating replica is built on.

type RatingStorer added in v0.8.77

type RatingStorer interface {
	Put(rec domain.RatingRecord) error
	List(peerID string) ([]domain.RatingRecord, error)
	PeerIDs() ([]string, error)
	DeleteExpired(dimension string, beforeBucket int64) error
	OnPut(hook func(domain.RatingRecord))
	OnDelete(hook func(domain.RatingRecord))
	Close() error
}

RatingStorer is the replicated record store the rating engine writes to.

Jump to

Keyboard shortcuts

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