Adds endpoint for fetching local block cids

This commit is contained in:
benbierens 2023-10-10 17:46:58 +02:00
parent 1875e6b0d6
commit 95c6bad370
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 21 additions and 2 deletions

View File

@ -361,6 +361,20 @@ proc initRestApi*(node: CodexNodeRef, conf: CodexConf): RestRouter =
}
return RestApiResponse.response($json)
router.api(
MethodGet,
"/api/codex/v1/debug/repostore") do () -> RestApiResponse:
let jarray = newJArray()
if cids =? await node.blockStore.listBlocks(BlockType.Both):
for c in cids:
if cid =? await c:
jarray.add(%*{
"cid": $cid
})
await sleepAsync(50.millis)
return RestApiResponse.response($jarray)
router.api(
MethodGet,
"/api/codex/v1/sales/slots") do () -> RestApiResponse:

View File

@ -86,13 +86,18 @@ method close*(self: NetworkStore): Future[void] {.async.} =
if not self.localStore.isNil:
await self.localStore.close
method listBlocks*(
self: NetworkStore,
blockType = BlockType.Manifest): Future[?!BlocksIter] {.async.} =
await self.localStore.listBlocks(blockType)
proc new*(
T: type NetworkStore,
engine: BlockExcEngine,
localStore: BlockStore
): NetworkStore =
## Create new instance of a NetworkStore
##
## Create new instance of a NetworkStore
##
NetworkStore(
localStore: localStore,
engine: engine)