add skipped master changes

This commit is contained in:
Dmitriy Ryajov 2023-11-13 20:43:14 -06:00
parent 0c704336e3
commit ac5ef27e84
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 34 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import ../errors
import ../manifest
import ../merkletree
import ../utils
import ../clock
export blockstore
@ -219,6 +220,16 @@ method putBlockCidAndProof*(
self.cidAndProofCache[(treeCid, index)] = (blockCid, proof)
success()
method ensureExpiry*(
self: CacheStore,
cid: Cid,
expiry: SecondsSince1970
): Future[?!void] {.async.} =
## Updates block's assosicated TTL in store - not applicable for CacheStore
##
discard # CacheStore does not have notion of TTL
method delBlock*(self: CacheStore, cid: Cid): Future[?!void] {.async.} =
## Delete a block from the blockstore
##
@ -239,7 +250,7 @@ method delBlock*(self: CacheStore, treeCid: Cid, index: Natural): Future[?!void]
if removed =? maybeRemoved:
return await self.delBlock(removed[0])
return success()
method close*(self: CacheStore): Future[void] {.async.} =

View File

@ -20,6 +20,7 @@ import pkg/libp2p
import ../blocktype
import ../utils/asyncheapqueue
import ../utils/asynciter
import ../clock
import ./blockstore
import ../blockexchange
@ -91,6 +92,27 @@ method putBlockCidAndProof*(
): Future[?!void] =
self.localStore.putBlockCidAndProof(treeCid, index, blockCid, proof)
method ensureExpiry*(
self: NetworkStore,
cid: Cid,
expiry: SecondsSince1970
): Future[?!void] {.async.} =
## Ensure that block's assosicated expiry is at least given timestamp
## If the current expiry is lower then it is updated to the given one, otherwise it is left intact
##
if (await self.localStore.hasBlock(cid)).tryGet:
return await self.localStore.ensureExpiry(cid, expiry)
else:
trace "Updating expiry - block not in local store", cid
return success()
method listBlocks*(
self: NetworkStore,
blockType = BlockType.Manifest): Future[?!AsyncIter[?Cid]] =
self.localStore.listBlocks(blockType)
method delBlock*(self: NetworkStore, cid: Cid): Future[?!void] =
## Delete a block from the blockstore
##