add future effective amount index
-increase lru cache size for effective amount column famlily to 64mb
This commit is contained in:
parent
99ddd208db
commit
abc5184e19
2 changed files with 43 additions and 1 deletions
|
@ -50,6 +50,7 @@ class DB_PREFIXES(enum.Enum):
|
|||
hashX_mempool_status = b'g'
|
||||
reposted_count = b'j'
|
||||
effective_amount = b'i'
|
||||
future_effective_amount = b'k'
|
||||
|
||||
|
||||
COLUMN_SETTINGS = {} # this is updated by the PrefixRow metaclass
|
||||
|
|
|
@ -1783,7 +1783,7 @@ class EffectiveAmountPrefixRow(PrefixRow):
|
|||
prefix = DB_PREFIXES.effective_amount.value
|
||||
key_struct = struct.Struct(b'>20s')
|
||||
value_struct = struct.Struct(b'>QQ')
|
||||
|
||||
cache_size = 1024 * 1024 * 64
|
||||
key_part_lambdas = [
|
||||
lambda: b'',
|
||||
struct.Struct(b'>20s').pack
|
||||
|
@ -1810,6 +1810,46 @@ class EffectiveAmountPrefixRow(PrefixRow):
|
|||
return cls.pack_key(claim_hash), cls.pack_value(effective_amount, support_sum)
|
||||
|
||||
|
||||
class FutureEffectiveAmountKey(NamedTuple):
|
||||
claim_hash: bytes
|
||||
|
||||
|
||||
class FutureEffectiveAmountValue(NamedTuple):
|
||||
future_effective_amount: int
|
||||
|
||||
|
||||
class FutureEffectiveAmountPrefixRow(PrefixRow):
|
||||
prefix = DB_PREFIXES.future_effective_amount.value
|
||||
key_struct = struct.Struct(b'>20s')
|
||||
value_struct = struct.Struct(b'>Q')
|
||||
cache_size = 1024 * 1024 * 64
|
||||
|
||||
key_part_lambdas = [
|
||||
lambda: b'',
|
||||
struct.Struct(b'>20s').pack
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def pack_key(cls, claim_hash: bytes):
|
||||
return super().pack_key(claim_hash)
|
||||
|
||||
@classmethod
|
||||
def unpack_key(cls, key: bytes) -> FutureEffectiveAmountKey:
|
||||
return FutureEffectiveAmountKey(*super().unpack_key(key))
|
||||
|
||||
@classmethod
|
||||
def pack_value(cls, future_effective_amount: int) -> bytes:
|
||||
return super().pack_value(future_effective_amount)
|
||||
|
||||
@classmethod
|
||||
def unpack_value(cls, data: bytes) -> FutureEffectiveAmountValue:
|
||||
return FutureEffectiveAmountValue(*cls.value_struct.unpack(data))
|
||||
|
||||
@classmethod
|
||||
def pack_item(cls, claim_hash: bytes, future_effective_amount: int):
|
||||
return cls.pack_key(claim_hash), cls.pack_value(future_effective_amount)
|
||||
|
||||
|
||||
class PrefixDB(BasePrefixDB):
|
||||
def __init__(self, path: str, reorg_limit: int = 200, max_open_files: int = 64,
|
||||
secondary_path: str = '', unsafe_prefixes: Optional[typing.Set[bytes]] = None):
|
||||
|
@ -1853,6 +1893,7 @@ class PrefixDB(BasePrefixDB):
|
|||
self.hashX_status = HashXStatusPrefixRow(db, self._op_stack)
|
||||
self.hashX_mempool_status = HashXMempoolStatusPrefixRow(db, self._op_stack)
|
||||
self.effective_amount = EffectiveAmountPrefixRow(db, self._op_stack)
|
||||
self.future_effective_amount = FutureEffectiveAmountPrefixRow(db, self._op_stack)
|
||||
|
||||
|
||||
def auto_decode_item(key: bytes, value: bytes) -> Union[Tuple[NamedTuple, NamedTuple], Tuple[bytes, bytes]]:
|
||||
|
|
Loading…
Reference in a new issue