mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-12 18:33:11 +00:00
add skipped master changes
This commit is contained in:
parent
0c704336e3
commit
ac5ef27e84
@ -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.} =
|
||||
|
||||
@ -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
|
||||
##
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user