INNER CODE UNIT · Python

__kv_map_to_bytes

opentimestamps/opentimestamps-server · otsserver/backup.py:112

    def __kv_map_to_bytes(kv_map):
        ctx = BytesSerializationContext()
        # Sorting the map elements to create chunks deterministically, but this is not mandatory for importing the chunk
        for key, value in sorted(kv_map.items()):
            ctx.write_varuint(len(key))
            ctx.write_bytes(key)
            ctx.write_varuint(len(value))
            ctx.write_bytes(value)

        return ctx.getbytes()

    def read_disk_cache(self, chunk):
        # For the disk cache we are using 6 digits file name which will support a total of 1 billion commitments,
        # because every chunk contain 1000 commitments. Supposing 1 commitment per second this could last for 32 years
        # which appear to be ok for this version
        chunk_str = "{0:0>6}".format(chunk)
        chunk_path = chunk_str[0:3]  # we create a path to avoid creating more than 1000 files per directory

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…