PyBitmessage/src/storage/storage.py

74 lines
1.8 KiB
Python
Raw Normal View History

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