IPFSNode class
The main IPFS node implementation.
Provides high-level APIs for content addressing, publishing, DHT operations, and peer-to-peer networking.
Platform Note: Storage behavior is platform-dependent. On VM platforms,
it uses the local file system. On Web platforms, it uses IndexedDB via the
IpfsPlatform abstraction.
IPFSNode acts as a facade, orchestrating specialized managers:
ContentManager: Handles files, directories, pinning, and CAR files.NetworkManager: Handles peer connectivity and provider discovery.ProtocolManager: Handles PubSub, IPNS, and DNSLink.
Constructors
- IPFSNode.fromContainer(ServiceContainer _container)
- Creates an IPFSNode from a pre-configured service container.
Properties
-
addresses
→ List<
String> -
Returns a List of multiaddresses this node is listening on.
no setter
-
bandwidthMetrics
→ Stream<
Map< String, dynamic> > -
Returns a Stream of bandwidth metrics as a Map.
no setter
- bitswap → BitswapHandler?
-
Returns the
BitswapHandlerinstance, ornullif not registered.no setter - blockStore → BlockStore
-
Returns the underlying
BlockStore.no setter -
connectedPeers
→ Future<
List< String> > -
Returns a Future that resolves to a List of currently connected peer IDs.
no setter
- datastore → Datastore
-
Returns the underlying
Datastore.no setter - dhtClient → DHTClient
-
Returns the
DHTClientfor peer and content discovery.no setter - dhtHandler → DHTHandler?
-
Returns the
DHTHandlerinstance, ornullif not registered.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isRunning → bool
-
Whether the node is currently running.
no setter
- mfs → MFSManager
-
Returns the Mutable File System (MFS) manager.
no setter
-
onNewContent
→ Stream<
String> -
Returns a Stream of new content CIDs added to this node.
no setter
- peerId → String
-
Returns the peer ID of this node.
no setter
- peerID → String
-
Returns the peer ID of this node.
no setter
-
pinnedCids
→ Future<
List< String> > -
Returns a Future that resolves to a List of CIDs currently pinned by this node.
no setter
- plugins → PluginManager
-
Returns the Plugin manager.
no setter
-
publicKey
→ Future<
String> -
Returns a Future that resolves to the public key of this node as a base64 encoded protobuf.
no setter
-
pubsubMessages
→ Stream<
PubSubMessage> -
Returns a Stream of incoming PubSubMessages for all subscribed topics.
no setter
- router → RouterInterface?
-
Returns the
RouterInterfaceused for networking, ornullif not available.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- securityManager → SecurityManager
-
Returns the SecurityManager.
no setter
- state → NodeState
-
Returns the current state of the node.
no setter
Methods
-
addDirectory(
Map< String, dynamic> directoryContent) → Future<String> -
Returns a Future that resolves to the CID of the added
directoryContent. -
addFile(
Uint8List data) → Future< String> -
Returns a Future that resolves to the CID of the added file
data. -
addFileStream(
Stream< List< dataStream) → Future<int> >String> -
Returns a Future that resolves to the CID of the added file from
dataStream. -
cat(
String cid) → Future< Uint8List?> -
Returns a Future that resolves to the raw content associated with the given
cid. -
connectToPeer(
String multiaddr) → Future< void> -
Returns a Future that completes when the node manually connects to a peer using its
multiaddr. -
disconnectFromPeer(
String peerIdOrAddr) → Future< void> -
Returns a Future that completes when the node gracefully disconnects from a peer identified by
peerIdOrAddr. -
exportCAR(
String cid) → Future< Uint8List> -
Returns a Future that resolves to the CAR file bytes for the given
cid. -
findProviders(
String cid) → Future< List< String> > -
Returns a Future that resolves to a List of multiaddresses for providers of the given
cid. -
get(
String cid, {String path = ''}) → Future< Uint8List?> -
Returns a Future that resolves to the content of a file or directory associated with the given
cid. -
getHealthStatus(
) → Future< Map< String, dynamic> > - Returns a Future that resolves to a health status map for all subsystems.
-
importCAR(
Uint8List carFile) → Future< void> -
Returns a Future that completes when the given CAR (Content Addressable Archive) file
carFileis imported. -
ls(
String cid) → Future< List< Link> > -
Returns a Future that resolves to a List of
Links representing the contents of an IPFS directory. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pin(
String cid) → Future< void> -
Returns a Future that completes when the given
cidis pinned to prevent it from being garbage collected. -
publish(
String topic, String message) → Future< void> -
Returns a Future that completes when the node publishes a
messageto a PubSubtopic. -
publishIPNS(
String cid, {required String keyName}) → Future< void> -
Returns a Future that completes when an IPNS record is published for the given
cid. -
requestBlock(
String cid, Peer peer) → Future< void> -
Returns a Future that completes when a specific block associated with
cidis requested from apeervia Bitswap. -
resolveDNSLink(
String domainName) → Future< String> -
Returns a Future that resolves to the CID corresponding to the given
domainNamevia DNSLink. -
resolveIPNS(
String name) → Future< String> -
Returns a Future that resolves to the CID corresponding to the IPNS
name. -
resolvePeerId(
String peerIdStr) → List< String> -
Resolves a
peerIdStrto its known multiaddresses. -
restart(
) → Future< void> - Returns a Future that completes when the IPFS node has restarted by performing a stop and then a start.
-
setGatewayMode(
GatewayMode mode, {String? customUrl}) → void - Sets the mode for retrieving content.
-
start(
) → Future< void> - Returns a Future that completes when the IPFS node and all its subsystems have started.
-
stop(
) → Future< void> - Returns a Future that completes when the IPFS node has stopped gracefully, releasing all resources.
-
subscribe(
String topic) → Future< void> -
Returns a Future that completes when the node subscribes to a PubSub
topic. -
toString(
) → String -
A string representation of this object.
inherited
-
unpin(
String cid) → Future< bool> -
Returns a Future that resolves to
trueif the givencidwas successfully unpinned from IPFS. -
unsubscribe(
String topic) → Future< void> -
Returns a Future that completes when the node unsubscribes from a PubSub
topic.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited