Help us shape the future of Go! Take the 2026 Go Developer Survey

node

package
v1.3.104 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package node pkg/cxo/node/config.go c2-net-cxo

Package node pkg/cxo/node/conn.go c2-net-cxo

Package node pkg/cxo/node/errors.go c2-net-cxo

Package node pkg/cxo/node/feed.go c2-net-cxo

Package node pkg/cxo/node/feeds.go c2-net-cxo

Package node pkg/cxo/node/handshake.go c2-net-cxo

Package node pkg/cxo/node/head.go c2-net-cxo

Package node pkg/cxo/node/logs.go c2-net-cxo

Package node pkg/cxo/node/node.go c2-net-cxo

Package node pkg/cxo/node/rpc.go c2-net-cxo

Package node pkg/cxo/node/rpc_client.go c2-net-cxo

Package node pkg/cxo/node/swarm.go c2-net-cxo

Package node pkg/cxo/node/transport_dmsg.go c2-net-cxo transport_dmsg.go implements the DMSG transport for CXO nodes, allowing CXO peer connections over skywire's DMSG network.

Package node pkg/cxo/node/transports.go c2-net-cxo

Index

Constants

View Source
const (
	Prefix                string        = "[node] "
	MaxConnections        int           = 1000 * 1000
	MaxPendingConnections int           = 1000
	MaxFillingTime        time.Duration = 2 * time.Minute
	MaxTotalFillTime      time.Duration = 10 * time.Minute
	MaxHeads              int           = 10
	ListenTCP             string        = ":8870"
	ListenUDP             string        = "" // don't listen
	RPCAddress            string        = ":8871"
	ResponseTimeout       time.Duration = 59 * time.Second
	Pings                 time.Duration = 118 * time.Second
	Public                bool          = false
)

default configurations

View Source
const (
	NewInConnPin  log.Pin = 1 << iota // new incoming connection
	NewOutConnPin                     // new outgoing connection

	ConnHskPin   // handshake logs
	ConnEstPin   // connection established
	CloseConnPin // connection closed (except ERR logs)

	MsgSendPin    // send msg
	MsgReceivePin // receive msg

	FillPin //

	FeedPin //

	DiscoveryPin // show discovery debug logs

	PEXPin // show peer exchange debug logs

	MsgPin  = MsgSendPin | MsgReceivePin // send/receive
	ConnPin = NewInConnPin | NewOutConnPin | ConnEstPin | ConnHskPin |
		CloseConnPin // connections
)

debug log pins

Variables

View Source
var (
	ErrAlreadyListen           = errors.New("already listen")
	ErrTimeout                 = errors.New("timeout")
	ErrClosed                  = errors.New("closed")
	ErrNotPublic               = errors.New("not a public server")
	ErrAlreadyHaveConnection   = errors.New("already have connection")
	ErrInvalidResponse         = errors.New("invalid response")
	ErrNotHeld                 = errors.New("object not held by the peer")
	ErrNoConnectionsToFillFrom = errors.New("no connections to fill from")
	ErrMaxHeadsLimit           = errors.New("max heads limit")
	ErrUnsubscribe             = errors.New("unsubscribe")
	ErrBlankFeed               = errors.New("blank feed")
	ErrConnLimit               = errors.New("max nubmber of connections exceeded")
	ErrPendConnLimit           = errors.New("max number of pending connections exceeded")
)

common errors

Functions

This section is empty.

Types

type Config

type Config struct {
	// SecKey allows to provide secret key.
	SecKey cipher.SecKey

	// Logger contains configurations of logger
	Logger log.Config

	// Config is configurations of skyobject.Container.
	*skyobject.Config

	// MaxConnections is limit of connections.
	MaxConnections int

	// MaxPendingConnections is limit of pending connections.
	MaxPendingConnections int

	// MaxHeads is limit of heads per feed.
	MaxHeads int

	// MaxFillingTime is the STALL limit for filling of a Root object: the max
	// time a fill may go WITHOUT fetching an object. The timer resets on every
	// successful object fetch, so a large Root that keeps making progress is
	// never aborted no matter how long its total fill takes — only a genuinely
	// stalled peer (no object delivered for this long) is treated as broken and
	// aborted with ErrTimeout (the Root refills when the publisher republishes).
	// This replaced a fixed TOTAL-time cap that killed big-but-progressing hub
	// Roots at the wall clock, which is the residual TPD churn (a single-source
	// feed whose large Root couldn't finish inside the flat cap never landed).
	// A hung fill still pins its "wanted" objects in the cache (which cleanDown
	// skips), so MaxTotalFillTime below bounds the absolute window — that pair
	// preserves the #3562/#3569 leak guard while letting slow fills complete.
	// The TPD aggregator pins its own tighter 90s stall override on top of this.
	MaxFillingTime time.Duration

	// MaxTotalFillTime is the HARD ceiling on a single Root's fill, independent
	// of progress: even a fill that keeps fetching objects is aborted once it
	// has run this long in total. It backstops the progress-reset MaxFillingTime
	// stall timer so a pathological source that dribbles one object every stall
	// window can't pin "wanted" objects indefinitely (the #3562 leak class).
	// Must be > MaxFillingTime; if <= 0 the package default (MaxTotalFillTime
	// const) is used, and a value <= the stall timer is bumped to the default.
	MaxTotalFillTime time.Duration

	// RPC is RPC listening address. Empty string disables RPC.
	RPC string

	// TCP configurations
	TCP NetConfig

	// UDP configurations
	UDP NetConfig

	OnConnect    OnConnectFunc
	OnDisconnect OnDisconnectFunc

	// Public makes the Node share its list of feeds.
	Public bool

	OnSubscribeRemote   OnSubscribeRemoteFunc
	OnUnsubscribeRemote OnUnsubscribeRemoteFunc

	OnRootReceived  OnRootReceivedFunc
	OnRootFilled    OnRootFilledFunc
	OnFillingBreaks OnFillingBreaksFunc

	// Peer callbacks
	OnPeerAdded   OnPeerAddedFunc
	OnPeerUpdated OnPeerUpdatedFunc
	OnPeerRemoved OnPeerRemovedFunc
}

A Config represents configurations of the Node.

func NewConfig

func NewConfig() (c *Config)

NewConfig returns new Config with default values

func (*Config) FromFlags

func (c *Config) FromFlags()

FromFlags used to get values for the Config from command line flags.

func (*Config) Validate

func (c *Config) Validate() (err error)

Validate configurations.

type Conn

type Conn struct {
	*transport.Connection
	// contains filtered or unexported fields
}

A Conn represent connection of the Node

func (*Conn) Address

func (c *Conn) Address() (address string)

Address returns remote address represetned as string

func (*Conn) Close

func (c *Conn) Close() (err error)

Close the Conn Close signals the connection to shut down. The connection is fully cleaned up asynchronously by run(). Use Done() to wait for full cleanup if needed.

func (*Conn) Done

func (c *Conn) Done() <-chan struct{}

Done returns a channel that is closed when run() has fully completed (connection removed from node maps, transport closed, OnDisconnect called).

func (*Conn) Feeds

func (c *Conn) Feeds() (feeds []cipher.PubKey)

Feeds returns list of feeds this connection share with peer

func (*Conn) Getter

func (c *Conn) Getter() skyobject.Getter

Getter returns a skyobject.Getter that fetches single objects by hash from this connection's remote peer on demand (one RqObject request per Get, hash-verified, bounded by the connection's ResponseTimeout).

Unlike a Root fill it neither walks an object graph nor writes anything to the node's container: each Get is an isolated request/response for exactly the requested object, and the caller decides what (if anything) to keep. Pairing it with (*Container).Preview yields a bounded, on-demand read of one chosen path through a Root without triggering or interfering with a concurrent whole-Root fill. The TPD aggregator uses this to pull just the small tp-list discovery leaf out of a Root whose bulky telemetry subtree can't finish filling within the conn's window.

func (*Conn) HasFeed added in v1.3.98

func (c *Conn) HasFeed(feed cipher.PubKey) bool

HasFeed reports whether this connection is subscribed to feed. Unlike Feeds, which walks every feed of the node, it is two map lookups on the node's feeds loop, so it is the one to ask per connection on a node holding thousands of feeds.

func (*Conn) IsIncoming

func (c *Conn) IsIncoming() (ok bool)

IsIncoming returns true if this Conn is incoming and accepted by listener

func (*Conn) IsOutgoing

func (c *Conn) IsOutgoing() (ok bool)

IsOutgoing is inverse of the IsIncoming

func (*Conn) Node

func (c *Conn) Node() (node *Node)

Node returns related Node

func (*Conn) PeerID

func (c *Conn) PeerID() (id cipher.PubKey)

PeerID is id of remote peer that used for internals and unique

func (*Conn) Preview

func (c *Conn) Preview(
	feed cipher.PubKey,
	previewFunc PreviewFunc,
) (
	err error,
)

Preview a feed of remote peer. The request is blocking. The Preview gets latest Root of given feed from remote peer and uses the peer to obtain objects this node does not have.

func (*Conn) RemoteFeeds

func (c *Conn) RemoteFeeds() (feeds []cipher.PubKey, err error)

RemoteFeeds requests list of feeds that remote peer share. It's possible if the remote peer is public server, otherwise it returns "not a public server" error. The request has timeout configured by Config

func (*Conn) String

func (c *Conn) String() string

String returns string "-> network://remote_address" for example: "-> tcp://127.0.0.1:8887". Where the arrow is "->" for incoming connections and is "<-" for outgoing

func (*Conn) Subscribe

func (c *Conn) Subscribe(feed cipher.PubKey) (err error)

Subscribe to gievn feed of remote peer. The Subscribe adds feed to the Node if the Node doesn't have the feed calling the (*Node).Share method. If request fails, then the feed is not removed. E.g. if the Subscribe method returns error then it probably adds given feed to the Node, but request fails. Or it can returns error of the (*Node).Share

func (*Conn) Unsubscribe

func (c *Conn) Unsubscribe(feed cipher.PubKey)

Unsubscribe from given feed of remote peer

type ConnFeed

type ConnFeed struct {
	Address string
	Feed    cipher.PubKey
}

A ConnFeed represents connection address and feed

type DMSG

type DMSG struct {
	*transport.DMSGFactory
	// contains filtered or unexported fields
}

DMSG represents the DMSG transport of a CXO Node. It manages CXO connections over DMSG, using public keys as addresses instead of IP:port.

func (*DMSG) CloseConn

func (d *DMSG) CloseConn(pk cipher.PubKey) error

CloseConn closes a connection by remote public key.

func (*DMSG) ConnectPK

func (d *DMSG) ConnectPK(ctx context.Context, remotePK cipher.PubKey) (*Conn, error)

ConnectPK connects to a remote CXO node over DMSG by public key. If a healthy connection already exists, returns the existing one.

ctx bounds the underlying dmsg.Client.Dial — when ctx is canceled or its deadline elapses before the dial completes, ConnectPK returns ctx.Err() rather than blocking on a half-dead transport. Pre-this-change the dmsg dial used context.Background(), so a peer hung at the dmsg layer would survive the caller's deadline (Manager.tryReconnectPeers, Session.ReconnectPeer, …) and pin a goroutine in the dial until OS-level keepalive fired.

Cached-Conn liveness gate: a cached Conn whose closeq is signaled (run loop has observed the underlying transport going away, but removeConn hasn't yet completed) OR whose underlying transport reports IsClosed() is evicted here and re-dialed. Without this gate, the symmetric peer-side bug fixed in #2625's acceptHandshake also manifested on the dial side: a half-dead Conn whose run loop is stuck in receiveMsg's select on a transport that will never return — closeq not closed yet — would be returned from this cache. Subsequent Subscribe calls on the dead Conn hang, reconnect timeouts pile up, and the visor's peerSubs go silent indefinitely.

Concretely observed in production (2026-05-16): after an Alpha visor restart, all 3 peerSubs to remote group members appeared healthy for ~35 seconds, then went silent. The per-peer reconnect loop from #2606 fired every 30s but every attempt timed out at 15s with "context deadline exceeded" — because every ConnectPK returned the same dead cached Conn, Subscribe hung on it, the outer 15s deadline fired. Forty-five minutes of silent stale peerSubs until manual halt+restart cleared the cache. This fix makes ConnectPK self-heal on the next reconnect tick.

The closeq check catches the explicit-close case; the IsClosed() check catches the case where the underlying transport's close was observed but run loop hasn't yet propagated. Neither catches the truly-half-dead-but-not-yet-erroring case (e.g. a wedged network with no FIN/RST) — that path needs a separate liveness pulse, deferred. For typical "peer's dmsg server flipped / transport reset cleanly" failures this is sufficient.

func (*DMSG) Connections

func (d *DMSG) Connections() []cipher.PubKey

Connections returns a list of connected remote public keys.

func (*DMSG) Drop

func (d *DMSG) Drop(pk cipher.PubKey)

Drop closes the conn to pk, so the next ConnectPK dials again.

func (*DMSG) Listen

func (d *DMSG) Listen() error

Listen starts accepting CXO connections over DMSG.

func (*DMSG) PeerAddr

func (d *DMSG) PeerAddr(pk cipher.PubKey) (net.Addr, bool)

PeerAddr returns the remote address of the live conn to pk, if there is one.

type DMSGConnFeed

type DMSGConnFeed struct {
	Peer cipher.PubKey
	Feed cipher.PubKey
}

DMSGConnFeed represents a DMSG peer and feed to subscribe to.

type DMSGRPC

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

DMSGRPC represents RPC methods for the DMSG transport.

func (*DMSGRPC) Connect

func (d *DMSGRPC) Connect(pk cipher.PubKey, _ *struct{}) error

Connect to a remote CXO node over DMSG by public key. net/rpc's method signature doesn't carry a ctx, so the dial is bounded only by the dmsg client's own timeouts. Callers that need cancellation must reach (*DMSG).ConnectPK directly with their own context.

func (*DMSGRPC) Connections

func (d *DMSGRPC) Connections(_ struct{}, pks *[]cipher.PubKey) error

Connections lists connected DMSG peers.

func (*DMSGRPC) Subscribe

func (d *DMSGRPC) Subscribe(cf DMSGConnFeed, _ *struct{}) error

Subscribe to a feed on a DMSG-connected peer.

type NetConfig

type NetConfig struct {
	// Listen is listening address. Blank string
	// disables listening.
	Listen string

	// ResponseTimeout is timeout for requests.
	ResponseTimeout time.Duration

	// Pings is interval for pinging peers.
	Pings time.Duration
}

NetConfig represents configurations of a TCP or UDP network

type Node

type Node struct {
	log.Logger // logger
	// contains filtered or unexported fields
}

A Node represents network P2P transport for CX objects. The node used to receive, send and retransmit CX objects. The Node cares about last Root object of active head (see skyobject.Index.ActiveHead) of a feed. E.g. the Node never replicates an old Root if there is a newer one. The Node uses TCP and UDP transports.

func NewNode

func NewNode(conf *Config) (n *Node, err error)

NewNode creates new Node instance using provided Config. If the Config is nil, then default is used (see NewConfig for defaults)

func NewNodeContainer

func NewNodeContainer(
	conf *Config,
	c *skyobject.Container,
) (
	n *Node,
	err error,
)

NewNodeContainer use provided Container. Configurations related to Container ignored.

func (*Node) Close

func (n *Node) Close() (err error)

Close the Node. The Close returns error of (skyobject.Container).Close once.

Note: connection close cascades drain shard mutexes rather than holding Node.mx — closing a Conn signals goroutines that may re-enter Node methods (removeConn, etc.) and pre-fix that re-entry deadlocked against the Node.mx held here.

func (*Node) Config

func (n *Node) Config() (conf *Config)

Config returns Config with which the Node was created. The Config must not be modified. If the Node created using NewNodeContainer, then Config field replaced with config of given Container

func (*Node) Connections

func (n *Node) Connections() (cs []*Conn)

Connections returns all established connections. Snapshots the sharded active map; no Node-wide lock held during the walk.

func (*Node) ConnectionsOfFeed

func (n *Node) ConnectionsOfFeed(feed cipher.PubKey) (cs []*Conn)

ConnectionsOfFeed returns list of connections of given feed. Use blank public key to get all connections that does not share a feed

func (*Node) Container

func (n *Node) Container() (c *skyobject.Container)

Container returns related Container instance

func (*Node) DMSG

func (n *Node) DMSG() *DMSG

DMSG returns the DMSG transport of the Node, or nil if not configured.

func (*Node) DontShare

func (n *Node) DontShare(feed cipher.PubKey) (err error)

DontShare given feed. The method does't remove the feed from underlying Container. The method calls Unsubscribe() for all connections that share the feed. The method does nothing if the Node doesn't share the feed The Node never sync with Container automatically, and before removing a feed from Container, call this method to prevent sharing feed that does not exist

func (*Node) EnableDMSG

func (n *Node) EnableDMSG(factory *transport.DMSGFactory) error

EnableDMSG creates and starts a DMSG transport on this node using the given DMSG factory. It starts listening for incoming CXO connections over DMSG.

func (*Node) Feeds

func (n *Node) Feeds() (feeds []cipher.PubKey)

Feeds the Node share. The reply is read-only

func (*Node) ID

func (n *Node) ID() (id cipher.PubKey)

ID retursn identifier of the Node. The identifier is unique random identifier that used to avoid cross-connections

func (*Node) InSwarm

func (n *Node) InSwarm(feed cipher.PubKey) (*Swarm, bool)

func (*Node) IsSharing

func (n *Node) IsSharing(feed cipher.PubKey) (ok bool)

IsSharing returns true if the Node is sharing given feed

func (*Node) JoinSwarm

func (n *Node) JoinSwarm(
	feed cipher.PubKey, cfg SwarmConfig) (*Swarm, error)

func (*Node) LeaveSwarm

func (n *Node) LeaveSwarm(feed cipher.PubKey) error

func (*Node) Publish

func (n *Node) Publish(r *registry.Root)

Publish sends given Root object to peers that subscribed to feed of the Root. The Publish used to publish new Root objects. E.g. the Node sends last Root object of a feed to subsctibers. But the Node knows nothing about new Root objects. And to share an updated Root, call the Publish. And don't call the publish for Root objects that alredy saved (that saved before subscription)

func (*Node) SetDMSG

func (n *Node) SetDMSG(d *DMSG)

SetDMSG sets the DMSG transport for this node. Must be called before Listen/Connect operations on the DMSG transport.

func (*Node) Share

func (n *Node) Share(feed cipher.PubKey) (err error)

Share given feed. By default the Node dousn't share a feed. Even if underlying Container have any. To start sharing a feed, call this method. Thus, you can keep some feeds locally. To share all feeds of the Container use following code

for _, pk := range n.Container().Feeds() {
    n.Share(pk)
 }

The Share method adds given feed to underlying Container calling (*skyobjec.Container).AddFeed() method. The method never return an error if given feed is already shared. The share never associate the feed with a connection. You should to call (*Conn).Subscribe to do that.

func (*Node) Stat

func (n *Node) Stat() (s *Stat)

Stat returns statistic of the Node

func (*Node) Stats

func (n *Node) Stats() PublisherStats

Stats returns a snapshot of the Node's publisher-side health counters + active gauges. Cheap: pure atomic loads — no shard mutex acquired.

func (*Node) SwapOnFillingBreaks

func (n *Node) SwapOnFillingBreaks(next func(*Node, *registry.Root, error)) (prev func(*Node, *registry.Root, error))

SwapOnFillingBreaks atomically replaces the OnFillingBreaks callback and returns the previous value. Mirror of SwapOnRootFilled.

func (*Node) SwapOnRootFilled

func (n *Node) SwapOnRootFilled(next func(*Node, *registry.Root)) (prev func(*Node, *registry.Root))

SwapOnRootFilled atomically replaces the OnRootFilled callback and returns the previous value. Used by pkg/cxo/treestore's Subscriber to chain its handler in front of any pre-existing one without racing the head goroutine's read at onRootFilled.

func (*Node) TCP

func (n *Node) TCP() (tcp *TCP)

TCP returns TCP transport of the Node

func (*Node) UDP

func (n *Node) UDP() (tcp *UDP)

UDP returns UDP transport of the Node

type OnConnectFunc

type OnConnectFunc func(c *Conn) (terminate error)

OnConnectFunc represents callback that called when a connection created and established. It's possible to terminate connection returning error

type OnDisconnectFunc

type OnDisconnectFunc func(c *Conn, reason error)

OnDisconnectFunc represents callback that called when a connection closed.

type OnFillingBreaksFunc

type OnFillingBreaksFunc func(n *Node, r *registry.Root, err error)

OnFillingBreaksFunc represents callback that called when a new Root object can't be filled.

type OnPeerAddedFunc

type OnPeerAddedFunc func(f cipher.PubKey, p Peer)

OnPeerAddedFunc

type OnPeerRemovedFunc

type OnPeerRemovedFunc func(f cipher.PubKey, p Peer)

OnPeerRemovedFunc

type OnPeerUpdatedFunc

type OnPeerUpdatedFunc func(f cipher.PubKey, p Peer)

OnPeerUpdatedFunc

type OnRootFilledFunc

type OnRootFilledFunc func(n *Node, r *registry.Root)

OnRootFilledFunc represents callback that called when new Root filled and can be used. The callback called once per Root.

type OnRootReceivedFunc

type OnRootReceivedFunc func(c *Conn, r *registry.Root) (reject error)

OnRootReceivedFunc represents callback that called when new Root objects received. It's possible to reject a received Root returning error by this function.

type OnSubscribeRemoteFunc

type OnSubscribeRemoteFunc func(c *Conn, feed cipher.PubKey) (reject error)

OnSubscribeRemoteFunc represents callback that called when a remote peer subscribes to some feed of the Node.

type OnUnsubscribeRemoteFunc

type OnUnsubscribeRemoteFunc func(c *Conn, feed cipher.PubKey)

OnUnsubscribeRemoteFunc represent callback that called when a remote peer unsubscribes from some feed.

type Peer

type Peer struct {
	PubKey     cipher.PubKey
	Metadata   []byte
	TCPAddr    string
	UDPAddr    string
	LastSeen   time.Time
	RetryTimes uint64
}

Peer

type PreviewFunc

type PreviewFunc func(pack registry.Pack, r *registry.Root) (subscribe bool)

PreviewFunc used by (*Conn).Preview method. The function receive registry.Pack and lates Root object. The Pack used to get objects from DB or from remote peer. If the function returns true, then the Node and the Connection will be subscribed to the feed. Given Pack and given Root can't be used outside the function.

type PublisherStats

type PublisherStats struct {
	SendMsgTimeouts   uint64 `json:"sendmsg_timeouts"`
	DeadConnsClosed   uint64 `json:"dead_conns_closed"`
	ActiveConnections int    `json:"active_connections"`
	ActiveFeeds       int    `json:"active_feeds"`
}

PublisherStats is the snapshot of CXO-publisher-side health counters. Surfaced upward (treestore.Publisher.Stats() → visor RPC → `skywire cli visor doctor`) so operators can spot a publisher fanout that's silently shedding subscribers without parsing WARN logs.

Counter semantics:

  • SendMsgTimeouts counts sendMsg-queue-full-timeout events. Each tick is one subscriber whose queue was blocked for the full sendMsgQueueTimeout window before the conn was force-closed. A non-zero counter is the smoking gun for the pre-#2538 stuck publisher pattern, now bounded but worth surfacing.
  • DeadConnsClosed counts Conn instances closed by sendMsg's timeout path. Today this is always equal to SendMsgTimeouts; kept distinct so future auto-close paths (idle, frame-error, etc.) can be counted without rebasing this struct.
  • ActiveConnections / ActiveFeeds are point-in-time gauges useful for sanity checking ("did my publisher lose all its subscribers?").

type RPC

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

A RPC represnet RPC server of the Node. The RPC is exported because the net/rpc package requires it. E.g. the RPC is registered by the rpc package. The RPC can't be used outside the Node.

Short words, the RPC is internal

func (*RPC) Config

func (r *RPC) Config(_ struct{}, config *Config) (err error)

Config is RPC method

func (*RPC) Connections

func (r *RPC) Connections(_ struct{}, cs *[]string) (_ error)

Connections is RPC method

func (*RPC) ConnectionsOfFeed

func (r *RPC) ConnectionsOfFeed(feed cipher.PubKey, cs *[]string) (_ error)

ConnectionsOfFeed is RPC method

func (*RPC) DontShare

func (r *RPC) DontShare(pk cipher.PubKey, _ *struct{}) (err error)

DontShare is RPC method

func (*RPC) Feeds

func (r *RPC) Feeds(_ struct{}, fs *[]cipher.PubKey) (_ error)

Feeds is RPC method

func (*RPC) IsSharing

func (r *RPC) IsSharing(pk cipher.PubKey, yep *bool) (_ error)

IsSharing is RPC method

func (*RPC) Share

func (r *RPC) Share(pk cipher.PubKey, _ *struct{}) (err error)

Share is RPC method

func (*RPC) Shutdown

func (r *RPC) Shutdown(_ struct{}, _ *struct{}) error

Shutdown gracefully stops the node

func (*RPC) Stat

func (r *RPC) Stat(_ struct{}, stat *Stat) (err error)

Stat is RPC method

type RPCClient

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

A RPCClient represents client for RPC methods of the Node

func NewRPCClient

func NewRPCClient(address string) (rc *RPCClient, err error)

NewRPCClient creates RPC client connected to RPC server with given address

func (*RPCClient) Close

func (r *RPCClient) Close() (err error)

Close client

func (*RPCClient) Node

func (r *RPCClient) Node() (n *RPCClientNode)

Node related methods

func (*RPCClient) Root

func (r *RPCClient) Root() (t *RPCClientRoot)

Root objects related methods

func (*RPCClient) TCP

func (r *RPCClient) TCP() (t *RPCClientTCP)

TCP related methods

func (*RPCClient) UDP

func (r *RPCClient) UDP() (t *RPCClientUDP)

UDP related methods

type RPCClientNode

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

An RPCClientNode implements RPC methods related to the Node

func (*RPCClientNode) Config

func (r *RPCClientNode) Config() (config *Config, err error)

Config of the Node

func (*RPCClientNode) Connections

func (r *RPCClientNode) Connections() (cs []string, err error)

Connections of the Node

func (*RPCClientNode) ConnectionsOfFeed

func (r *RPCClientNode) ConnectionsOfFeed(
	pk cipher.PubKey,
) (
	cs []string,
	err error,
)

ConnectionsOfFeed of the Node

func (*RPCClientNode) DontShare

func (r *RPCClientNode) DontShare(pk cipher.PubKey) (err error)

DontShare given feed

func (*RPCClientNode) Feeds

func (r *RPCClientNode) Feeds() (fs []cipher.PubKey, err error)

Feeds that the Node is shareing

func (*RPCClientNode) IsSharing

func (r *RPCClientNode) IsSharing(pk cipher.PubKey) (yep bool, err error)

IsSharing a feed or not

func (*RPCClientNode) Share

func (r *RPCClientNode) Share(pk cipher.PubKey) (err error)

Share given feed

func (*RPCClientNode) Shutdown

func (r *RPCClientNode) Shutdown() error

Shutdown gracefully stops the node

func (*RPCClientNode) Stat

func (r *RPCClientNode) Stat() (stat *Stat, err error)

Stat obtains statistic of the Node

type RPCClientRoot

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

A RPCClientRoot implements RPC methods related to Root objects

func (*RPCClientRoot) Last

func (r *RPCClientRoot) Last(
	feed cipher.PubKey,
) (
	z *registry.Root,
	err error,
)

Last Root object

func (*RPCClientRoot) Show

func (r *RPCClientRoot) Show(
	feed cipher.PubKey,
	nonce uint64,
	seq uint64,
) (
	z *registry.Root,
	err error,
)

Show brief information of Root object

func (*RPCClientRoot) Tree

func (r *RPCClientRoot) Tree(
	feed cipher.PubKey,
	nonce uint64,
	seq uint64,
) (
	tree string,
	err error,
)

Tree of Root object

type RPCClientTCP

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

A RPCClientTCP implements RPC methods related to TCP transport

func (*RPCClientTCP) Address

func (r *RPCClientTCP) Address() (address string, err error)

Address of TCP listener

func (*RPCClientTCP) Connect

func (r *RPCClientTCP) Connect(address string) (err error)

Connect to given TCP address

func (*RPCClientTCP) Disconnect

func (r *RPCClientTCP) Disconnect(address string) (err error)

Disconnect from peer

func (*RPCClientTCP) RemoteFeeds

func (r *RPCClientTCP) RemoteFeeds(
	address string,
) (
	rfs []cipher.PubKey,
	err error,
)

RemoteFeeds of peer

func (*RPCClientTCP) Subscribe

func (r *RPCClientTCP) Subscribe(address string, pk cipher.PubKey) (err error)

Subscribe to feed of peer

func (*RPCClientTCP) Unsubscribe

func (r *RPCClientTCP) Unsubscribe(
	address string,
	pk cipher.PubKey,
) (
	err error,
)

Unsubscribe from feed of peer

type RPCClientUDP

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

A RPCClientUDP implements RPC methods related to UDP transport

func (*RPCClientUDP) Address

func (r *RPCClientUDP) Address() (address string, err error)

Address of UDP listener

func (*RPCClientUDP) Connect

func (r *RPCClientUDP) Connect(address string) (err error)

Connect to peer

func (*RPCClientUDP) Disconnect

func (r *RPCClientUDP) Disconnect(address string) (err error)

Disconnect from peer

func (*RPCClientUDP) RemoteFeeds

func (r *RPCClientUDP) RemoteFeeds(
	address string,
) (
	rfs []cipher.PubKey,
	err error,
)

RemoteFeeds of peer

func (*RPCClientUDP) Subscribe

func (r *RPCClientUDP) Subscribe(address string, pk cipher.PubKey) (err error)

Subscribe to feed of peer

func (*RPCClientUDP) Unsubscribe

func (r *RPCClientUDP) Unsubscribe(
	address string,
	pk cipher.PubKey,
) (
	err error,
)

Unsubscribe from feed of peer

type RootRPC

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

A RootRPC represents RPC object of Root objects of the Node

func (*RootRPC) Last

func (r *RootRPC) Last(feed cipher.PubKey, z *registry.Root) (err error)

Last Root of given Feed (RPC method)

func (*RootRPC) Show

func (r *RootRPC) Show(rs RootSelector, z *registry.Root) (err error)

Show Root (RPC method)

func (*RootRPC) Tree

func (r *RootRPC) Tree(rs RootSelector, tree *string) (err error)

Tree of Root (RPC method)

type RootSelector

type RootSelector struct {
	Feed  cipher.PubKey
	Nonce uint64
	Seq   uint64
}

A RootSelector represents Root selector

type Stat

type Stat struct {
	*skyobject.Stat
	Fillavg time.Duration
}

A Stat represents Node stat

type Swarm

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

Swarm

func (*Swarm) AddPeer

func (s *Swarm) AddPeer(
	pk cipher.PubKey, meta []byte, tcp, udp string) error

func (*Swarm) Peers

func (s *Swarm) Peers() []Peer

func (*Swarm) RemovePeer

func (s *Swarm) RemovePeer(pk cipher.PubKey) error

type SwarmConfig

type SwarmConfig struct {
	MaxPeers        uint64
	RequestPeerRate time.Duration

	PeerExpirePeriod  time.Duration
	ClearOldPeersRate time.Duration

	MaxConns         uint64
	OutgoingConnRate time.Duration

	PeersPerResponse uint64
}

SwarmConfig defines on how node finds peers, belonging to the same swarm, and how it interacts with them later.

func DefaultSwarmConfig

func DefaultSwarmConfig() SwarmConfig

type TCP

type TCP struct {
	*transport.TCPFactory // underlying transport
	// contains filtered or unexported fields
}

A TCP represents TCP transport of the Node. The TCP used to listen and connect

func (*TCP) Address

func (t *TCP) Address() string

Address returns listening address as it passed to the Listen method. The address is blank string if the TCP is not listening

func (*TCP) Connect

func (t *TCP) Connect(address string) (*Conn, error)

Connect to given TCP address. The method blocks. If connection with given address already exists, then the Connect returns this existing connection.

func (*TCP) Listen

func (t *TCP) Listen(address string) (err error)

Listen on given address. It's possible to listen only once

type TCPRPC

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

A TCPRPC represents RPC object of TCP transport of the Node

func (*TCPRPC) Address

func (t *TCPRPC) Address(_ struct{}, address *string) (_ error)

Address is RPC method

func (*TCPRPC) Connect

func (t *TCPRPC) Connect(address string, _ *struct{}) (err error)

Connect is RPC method

func (*TCPRPC) Disconnect

func (t *TCPRPC) Disconnect(address string, _ *struct{}) (err error)

Disconnect is RPC method

func (*TCPRPC) RemoteFeeds

func (t *TCPRPC) RemoteFeeds(address string, rfs *[]cipher.PubKey) (err error)

RemoteFeeds is RPC method

func (*TCPRPC) Subscribe

func (t *TCPRPC) Subscribe(cf ConnFeed, _ *struct{}) (err error)

Subscribe is RPC method

func (*TCPRPC) Unsubscribe

func (t *TCPRPC) Unsubscribe(cf ConnFeed, _ *struct{}) (err error)

Unsubscribe is RPC method

type UDP

type UDP struct {
	*transport.UDPFactory // underlying transport
	// contains filtered or unexported fields
}

A UDP represents UDP transport of the Node. The UDP used to listen and connect

func (*UDP) Address

func (u *UDP) Address() string

Address returns listening address as it passed to the Listen method. The address is blank string if the UDP is not listening

func (*UDP) Connect

func (u *UDP) Connect(address string) (*Conn, error)

Connect to given UDP address. If connection with given address already exists, then the Connect returns this existing connection.

func (*UDP) Listen

func (u *UDP) Listen(address string) (err error)

Listen on given address. It's possible to listen only once

type UDPRPC

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

A UDPRPC represents RPC object of UDP transport of the Node

func (*UDPRPC) Address

func (u *UDPRPC) Address(_ struct{}, address *string) (_ error)

Address is RPC method

func (*UDPRPC) Connect

func (u *UDPRPC) Connect(address string, _ *struct{}) (err error)

Connect is RPC method

func (*UDPRPC) Disconnect

func (u *UDPRPC) Disconnect(address string, _ *struct{}) (err error)

Disconnect is RPC method

func (*UDPRPC) RemoteFeeds

func (u *UDPRPC) RemoteFeeds(address string, rfs *[]cipher.PubKey) (err error)

RemoteFeeds is RPC method

func (*UDPRPC) Subscribe

func (u *UDPRPC) Subscribe(cf ConnFeed, _ *struct{}) (err error)

Subscribe is RPC method

func (*UDPRPC) Unsubscribe

func (u *UDPRPC) Unsubscribe(cf ConnFeed, _ *struct{}) (err error)

Unsubscribe is RPC method

Directories

Path Synopsis
Package log pkg/cxo/node/log/log.go c2-net-cxo
Package log pkg/cxo/node/log/log.go c2-net-cxo
Package msg pkg/cxo/node/msg/msg.go c2-net-cxo
Package msg pkg/cxo/node/msg/msg.go c2-net-cxo
Package transport pkg/cxo/node/transport/connection.go c2-net-cxo
Package transport pkg/cxo/node/transport/connection.go c2-net-cxo

Jump to

Keyboard shortcuts

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