INNER CODE UNIT · Python
__getitem__
opentimestamps/opentimestamps-server · otsserver/backup.py:42
def __getitem__(self, chunk):
# We use a disk cache, creating a chunk of 1000 commitments is a quite expensive operation of about 10s.
# The server isn't blocked in the meantime but this could be used by an attacker to degrade calendar performance
# Moreover is not recommended to set up an HTTP cache more than one year (see RFC 2616), thus, a disk cache is
# mandatory.
cached_kv_bytes = self.read_disk_cache(chunk)
if cached_kv_bytes is not None:
return cached_kv_bytes
# TODO next code must be run only once, LOCK or something
backup_map = {}
start = chunk*PAGING
end = start+PAGING
# Iterate in reverse to fail fast if this chunk is not complete, a chunk is considered complete if all relative
# 1000 commitments are complete. Which means a tx with more of 6 confirmations timestamp them
for i in range(start, end)[::-1]: