Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Spit and polish
  • Loading branch information
rozhkovdmitrii committed Apr 10, 2022
commit 1903f4412c02c2857e3231244e020aa92ba526d8
11 changes: 6 additions & 5 deletions proxy/mempool/mem_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
@logged_group("neon.Proxy")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better to add a new logged_group 'neon.Mempool'.
This will show next stages in transaction processing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

class MemPool:

POOL_PROC_COUNT = 4
POOL_PROC_COUNT = 20

def __init__(self):
self._pool = Pool(processes=self.POOL_PROC_COUNT)

def on_eth_send_raw_transaction(self, *, eth_trx_hash):
self._pool.apply_async(self._on_eth_send_raw_transaction_impl, (eth_trx_hash,), {}, self.on_sending_trx_proceed, self.error_callback)
self._pool.apply_async(func=self._on_eth_send_raw_transaction_impl, args=(eth_trx_hash,),
callback=self.on_eth_send_raw_transaction_callback, error_callback=self.error_callback)

def error_callback(self, error):
self.error("Failed to invoke the function on worker process: ", error)
self.error("Failed to invoke on worker process: ", error)

def on_sending_trx_proceed(self, result):
self.debug(f"Sending transaction proceed: {result}")
def on_eth_send_raw_transaction_callback(self, result):
pass

def _on_eth_send_raw_transaction_impl(self, eth_trx_hash):
self.debug(f"Transaction is being processed on the worker: {eth_trx_hash}")
Expand Down
13 changes: 7 additions & 6 deletions proxy/mempool/mempool_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ class MemPoolService(QueueBasedService):
MEM_POOL_SERVICE_PORT = 9091

def __init__(self):
QueueBasedService.__init__(self, self.MEM_POOL_SERVICE_PORT)
self._mem_pool = MemPool()
QueueBasedService.__init__(self, self.MEM_POOL_SERVICE_PORT, True)
self._mem_pool = None

def on_eth_send_raw_transaction(self, *, eth_trx_hash):
self._mem_pool.on_eth_send_raw_transaction(eth_trx_hash=eth_trx_hash)

def do_extras(self):
self._mem_pool.do_extras()
# QueueBasedService abstracts

def __del__(self):
self.info("Delete Mempool service")
def service_process_init(self):
self._mem_pool = MemPool()

def do_extras(self):
self._mem_pool.do_extras()