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

61 lines
1.6 KiB
Python
Raw Normal View History

2019-09-26 10:42:15 +02:00
"""
src/storage/storage.py
======================
"""
import collections
InventoryItem = collections.namedtuple('InventoryItem', 'type stream payload expires tag')
2019-09-25 13:09:15 +02:00
class Storage(object):
2019-09-24 11:20:20 +02:00
"""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"""
def __init__(self):
2019-09-26 10:42:15 +02:00
# 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-09-26 10:42:15 +02:00
class MailboxStorage(Storage, collections.MutableMapping): # pylint: disable=abstract-method
"""Method for storing mails"""
def __init__(self):
2019-09-26 10:42:15 +02:00
# pylint: disable=super-init-not-called
pass