This repository has been archived on 2024-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-07/src/storage/storage.py

74 lines
1.8 KiB
Python
Raw Normal View History

2019-09-26 10:42:15 +02:00
"""
2019-12-24 13:53:48 +01:00
Storing inventory items
2019-09-26 10:42:15 +02:00
"""
import collections
2019-12-24 13:53:48 +01:00
InventoryItem = collections.namedtuple(
'InventoryItem', 'type stream payload expires tag')
2019-09-25 13:09:15 +02:00
2019-12-24 13:53:48 +01:00
class Storage(object): # pylint: disable=too-few-public-methods
"""Base class for storing inventory
(extendable for other items to store)"""
pass
2019-09-25 13:09:15 +02:00
class InventoryStorage(Storage, collections.MutableMapping):
2019-09-26 10:42:15 +02:00
"""Module used for inventory storage"""
2019-12-24 13:53:48 +01:00
def __init__(self): # pylint: disable=super-init-not-called
self.numberOfInventoryLookupsPerformed = 0
2019-09-26 10:42:15 +02:00
def __contains__(self, _):
raise NotImplementedError
2019-09-26 10:42:15 +02:00
def __getitem__(self, _):
raise NotImplementedError
2019-09-26 10:42:15 +02:00
def __setitem__(self, _, value):
raise NotImplementedError
2019-09-26 10:42:15 +02:00
def __delitem__(self, _):
raise NotImplementedError
def __iter__(self):
raise NotImplementedError
def __len__(self):
raise NotImplementedError
2017-06-24 12:13:35 +02:00
def by_type_and_tag(self, objectType, tag):
2019-09-24 11:20:20 +02:00
"""Return objects filtered by object type and tag"""
raise NotImplementedError
def unexpired_hashes_by_stream(self, stream):
2019-09-24 11:20:20 +02:00
"""Return unexpired inventory vectors filtered by stream"""
raise NotImplementedError
def flush(self):
2019-09-24 11:20:20 +02:00
"""Flush cache"""
raise NotImplementedError
def clean(self):
2019-09-24 11:20:20 +02:00
"""Free memory / perform garbage collection"""
raise NotImplementedError
2019-09-25 13:09:15 +02:00
2019-12-24 13:53:48 +01:00
class MailboxStorage(Storage, collections.MutableMapping):
2019-09-26 10:42:15 +02:00
"""Method for storing mails"""
2019-12-24 13:53:48 +01:00
def __delitem__(self, key):
raise NotImplementedError
def __getitem__(self, key):
raise NotImplementedError
def __iter__(self):
raise NotImplementedError
def __len__(self):
raise NotImplementedError
def __setitem__(self, key, value):
raise NotImplementedError