mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-20 00:28:07 +00:00
Adds endpoint for fetching local block cids
This commit is contained in:
parent
1875e6b0d6
commit
95c6bad370
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user