Merge pull request #3130 from lbryio/block-cache-metrics

skip null args in `channel_ids` given to `claim_search`
This commit is contained in:
Jack Robison 2020-12-30 20:57:56 -05:00 committed by GitHub
commit 82a030e6ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -55,7 +55,7 @@ class Daemon:
self.available_rpcs = {} self.available_rpcs = {}
self.connector = aiohttp.TCPConnector() self.connector = aiohttp.TCPConnector()
self._block_hash_cache = LRUCache(100000) self._block_hash_cache = LRUCache(100000)
self._block_cache = LRUCache(10000) self._block_cache = LRUCache(2**16, metric_name='block', namespace=NAMESPACE)
async def close(self): async def close(self):
if self.connector: if self.connector:
@ -249,8 +249,10 @@ class Daemon:
async def deserialised_block(self, hex_hash): async def deserialised_block(self, hex_hash):
"""Return the deserialised block with the given hex hash.""" """Return the deserialised block with the given hex hash."""
if not self._block_cache.get(hex_hash): if hex_hash not in self._block_cache:
self._block_cache[hex_hash] = await self._send_single('getblock', (hex_hash, True)) block = await self._send_single('getblock', (hex_hash, True))
self._block_cache[hex_hash] = block
return block
return self._block_cache[hex_hash] return self._block_cache[hex_hash]
async def raw_blocks(self, hex_hashes): async def raw_blocks(self, hex_hashes):

View file

@ -283,7 +283,7 @@ def claims_query(cols, for_count=False, **constraints) -> Tuple[str, Dict]:
channel_ids = constraints.pop('channel_ids') channel_ids = constraints.pop('channel_ids')
if channel_ids: if channel_ids:
constraints['claim.channel_hash__in'] = { constraints['claim.channel_hash__in'] = {
unhexlify(cid)[::-1] for cid in channel_ids unhexlify(cid)[::-1] for cid in channel_ids if cid
} }
if 'not_channel_ids' in constraints: if 'not_channel_ids' in constraints:
not_channel_ids = constraints.pop('not_channel_ids') not_channel_ids = constraints.pop('not_channel_ids')