示例#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)
    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)
示例#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)
    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)