tribler.core.database.serialization
Attributes
Exceptions
A block was received with an unknown blob type. |
Classes
A payload that captures a public key and metadata type and supports adding a signature over its contents. |
|
A signed payload that also includes an id, origin id, and a timestamp. |
|
Deprecated, do not use. |
|
Deprecated, do not use. |
|
Deprecated, do not use. |
|
Deprecated, do not use. |
|
Payload for metadata that stores a torrent. |
|
Deprecated, do not use. |
|
Deprecated, do not use. |
|
Payload for health item information. See the details of binary format in MetadataCompressor class description. |
Functions
|
Convert a datetime object to an int. |
|
Convert an int into a datetime object. |
|
Read the next payload from the data buffer (at the given offset). |
Module Contents
- tribler.core.database.serialization.EPOCH
- tribler.core.database.serialization.SIGNATURE_SIZE = 64
- tribler.core.database.serialization.NULL_SIG = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0...
- tribler.core.database.serialization.NULL_KEY = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0...
- tribler.core.database.serialization.TYPELESS = 100
- tribler.core.database.serialization.CHANNEL_NODE = 200
- tribler.core.database.serialization.METADATA_NODE = 210
- tribler.core.database.serialization.COLLECTION_NODE = 220
- tribler.core.database.serialization.JSON_NODE = 230
- tribler.core.database.serialization.CHANNEL_DESCRIPTION = 231
- tribler.core.database.serialization.BINARY_NODE = 240
- tribler.core.database.serialization.CHANNEL_THUMBNAIL = 241
- tribler.core.database.serialization.REGULAR_TORRENT = 300
- tribler.core.database.serialization.CHANNEL_TORRENT = 400
- tribler.core.database.serialization.DELETED = 500
- tribler.core.database.serialization.SNIPPET = 600
- tribler.core.database.serialization.time2int(date_time: datetime.datetime, epoch: datetime.datetime = EPOCH) int
Convert a datetime object to an int.
- Parameters:
date_time – The datetime object to convert.
epoch – The epoch time, defaults to Jan 1, 1970.
- Returns:
The int representation of date_time.
WARNING: TZ-aware timestamps are madhouse…
- tribler.core.database.serialization.int2time(timestamp: int, epoch: datetime.datetime = EPOCH) datetime.datetime
Convert an int into a datetime object.
- Parameters:
timestamp – The timestamp to be converted.
epoch – The epoch time, defaults to Jan 1, 1970.
- Returns:
The datetime representation of timestamp.
- exception tribler.core.database.serialization.UnknownBlobTypeException
Bases:
ExceptionA block was received with an unknown blob type.
We only support type:
300, REGULAR_TORRENT
- tribler.core.database.serialization.read_payload_with_offset(data: bytes, offset: int = 0) tuple[SignedPayload, int]
Read the next payload from the data buffer (at the given offset).
- class tribler.core.database.serialization.SignedPayload
Bases:
ipv8.messaging.lazy_payload.VariablePayloadA payload that captures a public key and metadata type and supports adding a signature over its contents.
This payload can be extended to allow more data to be signed.
- names = ['metadata_type', 'reserved_flags', 'public_key']
- format_list = ['H', 'H', '64s']
- signature: bytes = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0...
- classmethod from_signed_blob(serialized: bytes) Self
Read a SignedPayload from the given serialized form.
- classmethod from_dict(**kwargs) Self
Create a payload from the given data (an unpacked dict).
- class tribler.core.database.serialization.ChannelNodePayload
Bases:
SignedPayloadA signed payload that also includes an id, origin id, and a timestamp.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp']
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q']
- class tribler.core.database.serialization.MetadataNodePayload
Bases:
ChannelNodePayloadDeprecated, do not use.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp', 'title', 'tags']
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q', 'varlenIutf8', 'varlenIutf8']
- class tribler.core.database.serialization.JsonNodePayload
Bases:
ChannelNodePayloadDeprecated, do not use.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp', 'json_text']
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q', 'varlenIutf8']
- class tribler.core.database.serialization.BinaryNodePayload
Bases:
ChannelNodePayloadDeprecated, do not use.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp',...
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q', 'varlenI', 'varlenIutf8']
- class tribler.core.database.serialization.CollectionNodePayload
Bases:
MetadataNodePayloadDeprecated, do not use.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp', 'title',...
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q', 'varlenIutf8', 'varlenIutf8', 'Q']
- class tribler.core.database.serialization.TorrentMetadataPayload
Bases:
ChannelNodePayloadPayload for metadata that stores a torrent.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp', 'infohash',...
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q', '20s', 'Q', 'I', 'varlenIutf8', 'varlenIutf8', 'varlenIutf8']
- fix_pack_torrent_date(value: datetime.datetime | int) int
Auto-convert the torrent date to an integer if it is a
datetimeobject.
- classmethod fix_unpack_torrent_date(value: int) datetime.datetime
Auto-convert the torrent data from the integer wire format to a
datetimeobject.
- class tribler.core.database.serialization.ChannelMetadataPayload
Bases:
TorrentMetadataPayloadDeprecated, do not use.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'id_', 'origin_id', 'timestamp', 'infohash',...
- format_list = ['H', 'H', '64s', 'Q', 'Q', 'Q', '20s', 'Q', 'I', 'varlenIutf8', 'varlenIutf8', 'varlenIutf8', 'Q', 'Q']
- class tribler.core.database.serialization.DeletedMetadataPayload
Bases:
SignedPayloadDeprecated, do not use.
- names = ['metadata_type', 'reserved_flags', 'public_key', 'delete_signature']
- format_list = ['H', 'H', '64s', '64s']
- tribler.core.database.serialization.METADATA_TYPE_TO_PAYLOAD_CLASS
- class tribler.core.database.serialization.HealthItemsPayload
Bases:
ipv8.messaging.lazy_payload.VariablePayloadPayload for health item information. See the details of binary format in MetadataCompressor class description.
- format_list = ['varlenI']
- names = ['data']