lbry-sdk/lbry/blob/blob_info.py

33 lines
797 B
Python
Raw Normal View History

2019-01-22 18:47:46 +01:00
import typing
class BlobInfo:
__slots__ = [
'blob_hash',
'blob_num',
'length',
'iv',
'added_on',
'is_mine'
]
def __init__(
self, blob_num: int, length: int, iv: str,
2021-09-20 03:38:09 +02:00
blob_hash: typing.Optional[str] = None, added_on=0, is_mine=False):
2019-01-22 18:47:46 +01:00
self.blob_hash = blob_hash
self.blob_num = blob_num
self.length = length
self.iv = iv
self.added_on = added_on
self.is_mine = is_mine
2019-01-22 18:47:46 +01:00
def as_dict(self) -> typing.Dict:
d = {
'length': self.length,
'blob_num': self.blob_num,
'iv': self.iv,
}
if self.blob_hash: # non-terminator blobs have a blob hash
d['blob_hash'] = self.blob_hash
return d