diff --git a/codex/rest/api.nim b/codex/rest/api.nim index 08cd97d9..eb2e40e8 100644 --- a/codex/rest/api.nim +++ b/codex/rest/api.nim @@ -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: diff --git a/codex/stores/networkstore.nim b/codex/stores/networkstore.nim index 9e815caa..b57da14e 100644 --- a/codex/stores/networkstore.nim +++ b/codex/stores/networkstore.nim @@ -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)