BlockStore class
Persistent storage for content-addressed blocks in IPFS.
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.
Blocks are stored as files named by CID. The block index tracks CIDs only; block data is served from disk through a bounded in-memory LRU cache, so memory use does not grow with repository size.
Constructors
- BlockStore({required String path})
-
Creates a new BlockStore at the given
path.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- path → String
-
The filesystem path where blocks are stored.
final
- pinManager → PinManager
-
Returns the
PinManagerfor this blockstore.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
flush(
) → Future< void> - Flushes in-memory metadata and pin state to persistent storage.
-
gc(
) → Future< int> - Returns a Future that resolves to the number of blocks removed during garbage collection.
-
getAllBlocks(
) → Future< List< Block> > - Returns a Future that resolves to a List of all Blocks in the store.
-
getBlock(
String cid) → Future< GetBlockResponse> -
Returns a Future that resolves to a
GetBlockResponsefor the givencid. -
getStatus(
) → Future< Map< String, dynamic> > - Returns a Future that resolves to a status map for the BlockStore.
-
hasBlock(
String cid) → Future< bool> -
Returns a Future that resolves to
trueif a block with the givencidexists. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
putBlock(
Block block) → Future< AddBlockResponse> -
Returns a Future that resolves to an
AddBlockResponseafter storing the givenblock. -
removeBlock(
String cid) → Future< RemoveBlockResponse> -
Returns a Future that resolves to a
RemoveBlockResponseafter removing the block with the givencid. -
start(
) → Future< void> - Returns a Future that completes when the BlockStore and its pin manager have started.
-
stop(
) → Future< void> - Returns a Future that completes when the BlockStore has stopped and its state is saved.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- blockCacheCapacity → const int
- Maximum number of blocks retained in the in-memory read/write cache.