def pack(self, for_digest_calculation=False): """Pack this object Args: for_digest_calculation (bool): True if digest calculation Returns: bytes: packed binary data """ dat = bytearray() if not for_digest_calculation: dat.extend( bbclib_binary.to_bigint(self.asset_id, size=self.idlen_conf["asset_id"])) dat.extend( bbclib_binary.to_bigint(self.user_id, size=self.idlen_conf["user_id"])) dat.extend(bbclib_binary.to_2byte(len(self.nonce))) dat.extend(self.nonce) dat.extend(bbclib_binary.to_4byte(self.asset_file_size)) if self.asset_file_size > 0: dat.extend(bbclib_binary.to_bigint(self.asset_file_digest)) if isinstance(self.asset_body, dict): dat.extend(bbclib_binary.to_2byte(1)) astbdy = msgpack.dumps(self.asset_body) dat.extend(bbclib_binary.to_2byte(len(astbdy))) dat.extend(astbdy) else: dat.extend(bbclib_binary.to_2byte(0)) dat.extend(bbclib_binary.to_2byte(self.asset_body_size)) if self.asset_body_size > 0: dat.extend(self.asset_body) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ dat = bytearray(bbclib_binary.to_bigint(self.domain_id)) dat.extend(bbclib_binary.to_bigint(self.transaction_id, self.idlen_conf["transaction_id"])) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ dat = bytearray(bbclib_binary.to_bigint(self.asset_group_id, size=self.idlen_conf["asset_group_id"])) dat.extend(bbclib_binary.to_bigint(self.transaction_id, size=self.idlen_conf["transaction_id"])) dat.extend(bbclib_binary.to_2byte(self.event_index_in_ref)) dat.extend(bbclib_binary.to_2byte(len(self.sig_indices))) for i in range(len(self.sig_indices)): dat.extend(bbclib_binary.to_2byte(self.sig_indices[i])) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ dat = bytearray( bbclib_binary.to_bigint(self.transaction_id, size=self.idlen_conf["transaction_id"])) if self.asset_id is None: dat.extend(bbclib_binary.to_2byte(0)) else: dat.extend(bbclib_binary.to_2byte(1)) dat.extend( bbclib_binary.to_bigint(self.asset_id, size=self.idlen_conf["asset_id"])) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ dat = bytearray() dat.extend(bbclib_binary.to_2byte(len(self.asset_ids))) for h in self.asset_ids: dat.extend( bbclib_binary.to_bigint(h, size=self.idlen_conf["asset_id"])) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ dat = bytearray() dat.extend( bbclib_binary.to_bigint(self.asset_id, size=self.idlen_conf["asset_id"])) dat.extend(bbclib_binary.to_2byte(self.asset_body_size)) if self.asset_body_size > 0: dat.extend(self.asset_body) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ if self.asset_group_id is None: raise Exception("need asset_group_id in BBcEvent") dat = bytearray(bbclib_binary.to_bigint(self.asset_group_id, size=self.idlen_conf["asset_group_id"])) dat.extend(bbclib_binary.to_2byte(len(self.reference_indices))) for i in range(len(self.reference_indices)): dat.extend(bbclib_binary.to_2byte(self.reference_indices[i])) dat.extend(bbclib_binary.to_2byte(len(self.mandatory_approvers))) for i in range(len(self.mandatory_approvers)): dat.extend(bbclib_binary.to_bigint(self.mandatory_approvers[i], size=self.idlen_conf["user_id"])) dat.extend(bbclib_binary.to_2byte(self.option_approver_num_numerator)) dat.extend(bbclib_binary.to_2byte(self.option_approver_num_denominator)) for i in range(self.option_approver_num_denominator): dat.extend(bbclib_binary.to_bigint(self.option_approvers[i], size=self.idlen_conf["user_id"])) ast = self.asset.pack() dat.extend(bbclib_binary.to_4byte(len(ast))) dat.extend(ast) return bytes(dat)
def pack(self): """Pack this object Returns: bytes: packed binary data """ if self.asset_group_id is None: raise Exception("need asset_group_id in BBcRelation") dat = bytearray( bbclib_binary.to_bigint(self.asset_group_id, size=self.idlen_conf["asset_group_id"])) dat.extend(bbclib_binary.to_2byte(len(self.pointers))) for i in range(len(self.pointers)): pt = self.pointers[i].pack() dat.extend(bbclib_binary.to_2byte(len(pt))) dat.extend(pt) if self.asset is not None: ast = self.asset.pack() dat.extend(bbclib_binary.to_4byte(len(ast))) dat.extend(ast) else: dat.extend(bbclib_binary.to_4byte(0)) if self.version >= 2: if self.asset_raw is not None: ast = self.asset_raw.pack() dat.extend(bbclib_binary.to_4byte(len(ast))) dat.extend(ast) else: dat.extend(bbclib_binary.to_4byte(0)) if self.asset_hash is not None: ast = self.asset_hash.pack() dat.extend(bbclib_binary.to_4byte(len(ast))) dat.extend(ast) else: dat.extend(bbclib_binary.to_4byte(0)) return bytes(dat)