add method
- Uint8List data
Adds data and returns its CID.
Implementation
Future<CID> add(Uint8List data) async {
// Create a CID using the fromContent factory
final cid = await CID.fromContent(
data,
codec: 'raw',
hashType: 'sha2-256',
version: 1,
);
// Store via BlockStore (which handles platform storage)
// We create a Block object
final block = Block(cid: cid, data: data);
await _blockStore.putBlock(block);
// Also cache in memory for speed (optional, BlockStore relies on platform)
// _store is redundant if WebBlockStore uses platform directly.
// We remove _store usage to rely on WebBlockStore + Platform.
return cid;
}