chaind-eth

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

commit f96134565257adda575d0f332e80e45eb6ddd77d
parent 58d801aa863512674a9a8fe9b7a39d7197ed4687
Author: lash <dev@holbrook.no>
Date:   Tue, 26 Apr 2022 15:43:18 +0000

Add socket send option to send script

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

diff --git a/chaind/eth/runnable/send.py b/chaind/eth/runnable/send.py @@ -82,6 +82,20 @@ if config.get('_SOURCE') == None: sys.exit(1) +class SocketSender: + + def __init__(self, config): + self.path = config.get('_SOCKET') + + def send(self, tx): + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.connect(self.path) + s.sendall(tx.encode('utf-8')) + r = s.recv(68) + s.close() + return r + + def main(): token_resolver = None if config.get('TOKEN_MODULE') != None: @@ -103,6 +117,11 @@ def main(): sys.stderr.write('processing error: {}. processors: {}\n'.format(str(e), str(processor))) sys.exit(1) + sender = None + if config.get('_RPC_SEND'): + if config.get('_SOCKET') != None: + sender = SocketSender(config) + tx_iter = iter(processor) out = Outputter(mode) while True: @@ -112,6 +131,9 @@ def main(): except StopIteration: break tx_hex = tx_bytes.hex() + if sender != None: + r = sender.send(tx_hex) + logg.info('sent {} result {}'.format(tx_hex, r)) print(out.do(tx_hex)) diff --git a/chaind/eth/runnable/tasker.py b/chaind/eth/runnable/tasker.py @@ -96,6 +96,8 @@ ctrl = SessionController(config, queue_adapter, process_outgoing) signal.signal(signal.SIGINT, ctrl.shutdown) signal.signal(signal.SIGTERM, ctrl.shutdown) +logg.info('session id is ' + config.get('SESSION_ID')) +logg.info('session socket path is ' + config.get('SESSION_SOCKET_PATH')) def main(): while True: diff --git a/systemd/chaind-eth-queue@.service b/systemd/chaind-eth-queue@.service @@ -1,7 +1,7 @@ [Unit] Description=Chainqueue transaction dispatch interface -Requires=chaind-eth-sync@.service -After=chaind-eth-sync@.service +#Requires=chaind-eth-sync@.service +#After=chaind-eth-sync@.service [Service] Environment="SESSION_ID=%i"