fix incorrectly caching mempool txs
This commit is contained in:
parent
5fc6f54152
commit
5763d38017
2 changed files with 6 additions and 2 deletions
|
@ -1003,7 +1003,7 @@ class HubDB:
|
||||||
],
|
],
|
||||||
'pos': tx_pos
|
'pos': tx_pos
|
||||||
}
|
}
|
||||||
if tx_height + 10 < self.db_height:
|
if tx_height > 0 and tx_height + 10 < self.db_height:
|
||||||
self._tx_and_merkle_cache[tx_hash] = tx, merkle
|
self._tx_and_merkle_cache[tx_hash] = tx, merkle
|
||||||
return None if not tx else tx.hex(), merkle
|
return None if not tx else tx.hex(), merkle
|
||||||
|
|
||||||
|
|
|
@ -1657,7 +1657,10 @@ class LBRYElectrumX(asyncio.Protocol):
|
||||||
f'network rules.\n\n{message}\n[{raw_tx}]')
|
f'network rules.\n\n{message}\n[{raw_tx}]')
|
||||||
|
|
||||||
async def transaction_info(self, tx_hash: str):
|
async def transaction_info(self, tx_hash: str):
|
||||||
return (await self.transaction_get_batch(tx_hash))[tx_hash]
|
tx_info = (await self.transaction_get_batch(tx_hash))[tx_hash]
|
||||||
|
if tx_info[0] is None and tx_info[1]['block_height'] == -1:
|
||||||
|
return RPCError(BAD_REQUEST, "No such mempool or blockchain transaction.")
|
||||||
|
return tx_info
|
||||||
|
|
||||||
async def transaction_get_batch(self, *tx_hashes):
|
async def transaction_get_batch(self, *tx_hashes):
|
||||||
self.session_manager.tx_request_count_metric.inc(len(tx_hashes))
|
self.session_manager.tx_request_count_metric.inc(len(tx_hashes))
|
||||||
|
@ -1683,6 +1686,7 @@ class LBRYElectrumX(asyncio.Protocol):
|
||||||
raw_tx = await asyncio.get_event_loop().run_in_executor(None, self.db.get_raw_tx, tx_hash_bytes)
|
raw_tx = await asyncio.get_event_loop().run_in_executor(None, self.db.get_raw_tx, tx_hash_bytes)
|
||||||
if raw_tx:
|
if raw_tx:
|
||||||
return raw_tx.hex()
|
return raw_tx.hex()
|
||||||
|
return RPCError("No such mempool or blockchain transaction.")
|
||||||
|
|
||||||
def _get_merkle_branch(self, tx_hashes, tx_pos):
|
def _get_merkle_branch(self, tx_hashes, tx_pos):
|
||||||
"""Return a merkle branch to a transaction.
|
"""Return a merkle branch to a transaction.
|
||||||
|
|
Loading…
Reference in a new issue