Ejemplo n.º 1
0
    def open(cls, fd):
        """Open an existing timestamp log

        fd must be positioned at the start of the log; the header will be
        immediately read and DeserializationError raised if incorrect.
        """
        ctx = StreamDeserializationContext(fd)

        actual_magic = ctx.read_bytes(len(cls.HEADER_MAGIC))

        if cls.HEADER_MAGIC != actual_magic:
            raise BadMagicError(cls.HEADER_MAGIC, actual_magic)

        file_hash_op = CryptOp.deserialize(ctx)

        return cls(fd, file_hash_op)
Ejemplo n.º 2
0
    def open(cls, fd):
        """Open an existing timestamp log

        fd must be positioned at the start of the log; the header will be
        immediately read and DeserializationError raised if incorrect.
        """
        ctx = StreamDeserializationContext(fd)

        actual_magic = ctx.read_bytes(len(cls.HEADER_MAGIC))

        if cls.HEADER_MAGIC != actual_magic:
            raise opentimestamps.core.serialize.BadMagicError(cls.HEADER_MAGIC, actual_magic)

        file_hash_op = CryptOp.deserialize(ctx)

        return cls(fd, file_hash_op)
Ejemplo n.º 3
0
    def __iter__(self):
        """Iterate through all timestamps in the timestamp log"""
        while True:
            try:
                reader = PacketReader(self.fd)
            except PacketMissingError:
                break

            ctx = StreamDeserializationContext(reader)

            try:
                length = ctx.read_varuint()
                file_hash = ctx.read_bytes(self.file_hash_op.DIGEST_LENGTH)
                timestamp = Timestamp.deserialize(ctx, file_hash)
                yield (length, timestamp)
            except DeserializationError as exp:
                # FIXME: should provide a way to get insight into these errors
                pass
Ejemplo n.º 4
0
    def __iter__(self):
        """Iterate through all timestamps in the timestamp log"""
        while True:
            try:
                reader = PacketReader(self.fd)
            except PacketMissingError:
                break

            ctx = StreamDeserializationContext(reader)

            try:
                length = ctx.read_varuint()
                file_hash = ctx.read_bytes(self.file_hash_op.DIGEST_LENGTH)
                timestamp = Timestamp.deserialize(ctx, file_hash)
                yield (length, timestamp)
            except DeserializationError as exp:
                # FIXME: should provide a way to get insight into these errors
                pass