Ejemplo n.º 1
0
    def create(cls, fd, file_hash_op):
        """Create a new timestamp log

        Writes the header appropriately.
        """
        ctx = StreamSerializationContext(fd)

        ctx.write_bytes(cls.HEADER_MAGIC)
        file_hash_op.serialize(ctx)

        return cls(fd, file_hash_op)
Ejemplo n.º 2
0
    def create(cls, fd, file_hash_op):
        """Create a new timestamp log

        Writes the header appropriately.
        """
        ctx = StreamSerializationContext(fd)

        ctx.write_bytes(cls.HEADER_MAGIC)
        file_hash_op.serialize(ctx)

        return cls(fd, file_hash_op)
Ejemplo n.º 3
0
    def append(self, length, timestamp):
        """Add a new timestamp to the log"""
        if len(timestamp.msg) != self.file_hash_op.DIGEST_LENGTH:
            raise ValueError(
                "Timestamp msg length does not match expected digest length; %d != %d"
                % (len(timestamp.msg), self.file_hash_op.DIGEST_LENGTH))

        with PacketWriter(self.fd) as packet_fd:
            ctx = StreamSerializationContext(packet_fd)
            ctx.write_varuint(length)
            ctx.write_bytes(timestamp.msg)
            timestamp.serialize(ctx)
Ejemplo n.º 4
0
    def append(self, length, timestamp):
        """Add a new timestamp to the log"""
        if len(timestamp.msg) != self.file_hash_op.DIGEST_LENGTH:
            raise ValueError(
                "Timestamp msg length does not match expected digest length; %d != %d"
                % (len(timestamp.msg), self.file_hash_op.DIGEST_LENGTH)
            )

        with PacketWriter(self.fd) as packet_fd:
            ctx = StreamSerializationContext(packet_fd)
            ctx.write_varuint(length)
            ctx.write_bytes(timestamp.msg)
            timestamp.serialize(ctx)