node

package
v0.0.0-...-285f5d4 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSwarmKey

func FormatSwarmKey(hexKey string) (io.Reader, error)

FormatSwarmKey takes a hex-encoded 32-byte key and returns a reader in the standard IPFS swarm key file format.

func LoadSavedBootstrapPeers

func LoadSavedBootstrapPeers(dataDir string) []string

LoadSavedBootstrapPeers reads multiaddrs from bootstrap_peers.txt in dataDir.

func NewPinnedBlockService

func NewPinnedBlockService(split *SplitBlockstore, exchange *bitswap.Bitswap) blockservice.BlockService

NewPinnedBlockService creates a blockservice that writes to the pinned store.

func ParseSwarmKey

func ParseSwarmKey(hexKey string) (pnet.PSK, error)

ParseSwarmKey takes a hex-encoded swarm key string and returns a PSK.

func SaveBootstrapPeer

func SaveBootstrapPeer(dataDir, multiaddr string) error

SaveBootstrapPeer appends a multiaddr to bootstrap_peers.txt.

Types

type CacheEvictor

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

CacheEvictor monitors cache disk usage and evicts the oldest blocks when the cache exceeds its size limit. It uses file modification time as a proxy for LRU ordering.

func NewCacheEvictor

func NewCacheEvictor(cacheDir string, maxBytes int64) *CacheEvictor

NewCacheEvictor creates a new evictor. If maxBytes is 0, eviction is disabled.

func (*CacheEvictor) Run

func (e *CacheEvictor) Run(ctx context.Context)

Run starts the eviction loop. It blocks until ctx is cancelled.

type Node

type Node struct {
	Host         host.Host
	DHT          *dht.IpfsDHT
	Bitswap      *bitswap.Bitswap
	BlockService blockservice.BlockService
	DAGService   ipld.DAGService
	Pinner       pinner.Pinner
	Blockstore   *SplitBlockstore
	PinMeta      *PinMeta
	DataDir      string
	SwarmKey     string
	// contains filtered or unexported fields
}

Node is the core IPFS node, owning all subsystems.

func Start

func Start(ctx context.Context, cfg *config.Config) (*Node, error)

Start creates and wires all IPFS subsystems.

func (*Node) BootstrapMultiaddr

func (n *Node) BootstrapMultiaddr(funnelHostname string) string

BootstrapMultiaddr returns this node's multiaddr for sharing with others. Uses the Funnel hostname so it's reachable from outside the tailnet.

func (*Node) Close

func (n *Node) Close() error

Close shuts down all subsystems in reverse order.

func (*Node) ConnectPeer

func (n *Node) ConnectPeer(ctx context.Context, multiaddr string, save bool) error

ConnectPeer connects to a peer by multiaddr string and optionally saves it.

func (*Node) GatewayHandler

func (n *Node) GatewayHandler() (http.Handler, error)

GatewayHandler returns an http.Handler for the public IPFS gateway.

type PinMeta

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

PinMeta stores supplementary metadata (like timestamps) for pins. The pinner itself doesn't track when pins were created.

func NewPinMeta

func NewPinMeta(dataDir string) (*PinMeta, error)

func (*PinMeta) Delete

func (pm *PinMeta) Delete(cid string)

func (*PinMeta) Get

func (pm *PinMeta) Get(cid string) (PinMetaEntry, bool)

func (*PinMeta) Set

func (pm *PinMeta) Set(cid string)

type PinMetaEntry

type PinMetaEntry struct {
	PinnedAt time.Time `json:"pinned_at"`
}

type SplitBlockstore

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

SplitBlockstore routes blocks to either a pinned store or a cache store. Blocks added via PinPut go to the pinned store. All other writes (e.g. from bitswap) go to the cache store. Reads check both stores, pinned first.

func OpenSplitBlockstore

func OpenSplitBlockstore(dataDir string) (*SplitBlockstore, ds.Batching, ds.Batching, error)

OpenSplitBlockstore creates two flatfs-backed blockstores under dataDir.

func (*SplitBlockstore) AllKeysChan

func (s *SplitBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

AllKeysChan returns CIDs from both stores.

func (*SplitBlockstore) DeleteBlock

func (s *SplitBlockstore) DeleteBlock(ctx context.Context, c cid.Cid) error

DeleteBlock removes a block from both stores.

func (*SplitBlockstore) Get

func (s *SplitBlockstore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error)

Get retrieves a block, checking pinned store first.

func (*SplitBlockstore) GetSize

func (s *SplitBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error)

GetSize returns block size, checking pinned store first.

func (*SplitBlockstore) Has

func (s *SplitBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)

Has checks if a block exists in either store.

func (*SplitBlockstore) PinPut

func (s *SplitBlockstore) PinPut(ctx context.Context, blk blocks.Block) error

PinPut stores a block in the pinned store. Used when explicitly adding content.

func (*SplitBlockstore) PinPutMany

func (s *SplitBlockstore) PinPutMany(ctx context.Context, blks []blocks.Block) error

PinPutMany stores multiple blocks in the pinned store.

func (*SplitBlockstore) Put

func (s *SplitBlockstore) Put(ctx context.Context, blk blocks.Block) error

Put stores a block in the cache store (default for bitswap/network content).

func (*SplitBlockstore) PutMany

func (s *SplitBlockstore) PutMany(ctx context.Context, blks []blocks.Block) error

PutMany stores multiple blocks in the cache store.

Jump to

Keyboard shortcuts

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