mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-08-11 03:13:11 +00:00
Blockstores: added API
parent
c2982fb665
commit
597828cf20
@ -1,6 +1,6 @@
|
||||
_This wiki page is temporary - it's a prototype for https://github.com/status-im/nim-codex/tree/main/codex/stores/readme.md_
|
||||
|
||||
This directory contains implementations for blockstores. Blockstore is a storage of datablocks (seq[byte]) addressed by strings, i.e. it's a hashtable-like interface.
|
||||
This directory contains implementations for blockstores. Blockstore is a storage of datablocks (seq[byte]) addressed by cids (strings), i.e. it's a hashtable-like interface.
|
||||
|
||||
Modules:
|
||||
- [blockstore.nim](https://github.com/status-im/nim-codex/blob/main/codex/stores/blockstore.nim) - abstract base class and API definition
|
||||
@ -8,3 +8,26 @@ Modules:
|
||||
- [fsstore.nim](https://github.com/status-im/nim-codex/blob/main/codex/stores/fsstore.nim) - disk-based store with each block stored in separate file, backed up by [cachestore.nim](cachestore.nim) for least recently used blocks
|
||||
- [networkstore.nim](https://github.com/status-im/nim-codex/blob/main/codex/stores/networkstore.nim) - retrieves data from the network (peers), backed up by local [fsstore.nim](fsstore.nim)
|
||||
|
||||
API:
|
||||
```Nim
|
||||
method getBlock*(self: BlockStore, cid: Cid): Future[?! (?Block)]
|
||||
## Get a block from the store. If no block corresponds to the given cid,
|
||||
## returns Block.none.success. On error, returns Block.failure(exception),
|
||||
## and implementations tend to `trace` the error message
|
||||
|
||||
method putBlock*(self: BlockStore, blk: Block): Future[?!void]
|
||||
## Put a block to the blockstore (blk contains both cid and block contents)
|
||||
|
||||
method delBlock*(self: BlockStore, cid: Cid): Future[?!void]
|
||||
## Delete a block from the blockstore
|
||||
|
||||
method hasBlock*(self: BlockStore, cid: Cid): Future[?!bool]
|
||||
## Check if the block exists in the blockstore
|
||||
|
||||
method listBlocks*(self: BlockStore, onBlock: OnBlock): Future[?!void]
|
||||
## Get the list of blocks in the BlockStore. This is an intensive operation
|
||||
|
||||
proc contains*(self: BlockStore, blk: Cid): Future[bool]
|
||||
## Check if the block exists in the blockstore.
|
||||
## Return false if error encountered
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user