Skip to content
Merged
Prev Previous commit
Next Next commit
optimize proccess spawning
  • Loading branch information
otselnik committed May 16, 2022
commit a07f4af993858e367c8f7e2406781805b8e310ca
15 changes: 11 additions & 4 deletions proxy/indexer/indexer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def get_tx_receipts(self, stop_slot=None):
tx_list.append(signature)
if len(tx_list) >= 20:
poll_txs.append(tx_list)
poll_txs.append(tx_list)
if len(tx_list) > 0:
poll_txs.append(tx_list)
self._get_txs(poll_txs)

for signature in signatures:
Expand Down Expand Up @@ -172,11 +173,17 @@ def _get_signatures(self, before: Optional[str], until: Optional[str], limit: in
return result

def _get_txs(self, poll_txs: List[List[str]]) -> None:
pool = ThreadPool(PARALLEL_REQUESTS)
pool.map(self._get_tx_receipts, poll_txs)
poll_txs.clear()
self.debug(f'{len(poll_txs)}')
if len(poll_txs) > 1:
pool = ThreadPool(min(PARALLEL_REQUESTS, len(poll_txs)))
pool.map(self._get_tx_receipts, poll_txs)
poll_txs.clear()
else:
if len(poll_txs) > 0:
self._get_tx_receipts(poll_txs[0])

def _get_tx_receipts(self, sign_list: List[str]) -> None:
self.debug(f'{len(sign_list)}')
if len(sign_list) == 0:
return

Expand Down