chaind-eth

Queue server for ethereum
Log | Files | Refs | README | LICENSE

commit dab50dadd1a2c5ae1d972c8b39a8b44524c07e90
parent 9cd89f4a836822ac54f9b2c9b55a0fa8c49e9da4
Author: lash <dev@holbrook.no>
Date:   Sun, 10 Apr 2022 17:13:49 +0000

Add response on socket

Diffstat:
Mchaind/eth/runnable/tasker.py | 22++++++++++++++--------
Msystemd/chaind-eth-queue@.service | 2+-
2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/chaind/eth/runnable/tasker.py b/chaind/eth/runnable/tasker.py @@ -99,9 +99,10 @@ signal.signal(signal.SIGTERM, ctrl.shutdown) def main(): while True: - r = None + v = None + client_socket = None try: - r = ctrl.get() + (client_socket, v) = ctrl.get() except ClientGoneError: break except ClientBlockError: @@ -111,21 +112,26 @@ def main(): except NothingToDoError: pass - if r == None: + if v == None: ctrl.process(conn) continue + result_data = None + r = 0 # no error try: - tx_hash = queue_adapter.put(r.hex()) + result_data = queue_adapter.put(v.hex()) except DuplicateTxError as e: - logg.error('tx already exists as {}'.format(e)) - continue + logg.error('tx already exists: {}'.format(e)) + r = 1 except ValueError as e: - logg.error('adapter rejected input {}: "{}"'.format(r.hex(), e)) + logg.error('adapter rejected input {}: "{}"'.format(v.hex(), e)) continue - queue_adapter.enqueue(tx_hash) + if r == 0: + queue_adapter.enqueue(result_data) + ctrl.respond_put(client_socket, r, extra_data=result_data) + if __name__ == '__main__': main() diff --git a/systemd/chaind-eth-queue@.service b/systemd/chaind-eth-queue@.service @@ -6,5 +6,5 @@ After=chaind-eth-sync@.service [Service] Environment="SESSION_ID=%i" Environment="SESSION_RUNTIME_DIR=/run/user/%U/chaind/eth" -ExecStart=%h/.local/bin/chaind-eth-server -v --session-id %i +ExecStart=%h/.local/bin/chaind-eth-tasker -v --session-id %i Restart=on-failure