Add tcp server
This commit is contained in:
parent
5b8f07bafc
commit
e6072da8e4
@ -3,6 +3,7 @@
|
|||||||
- Remove unused insert_key method in keystore interface
|
- Remove unused insert_key method in keystore interface
|
||||||
- Add transaction executor helper, with adapter helper for eth
|
- Add transaction executor helper, with adapter helper for eth
|
||||||
- Fix bitlength of integers in all tx fields before rlp encoding
|
- Fix bitlength of integers in all tx fields before rlp encoding
|
||||||
|
- Add tcp server
|
||||||
* 0.4.12
|
* 0.4.12
|
||||||
- Enforce hex strings in signer backend for sign message
|
- Enforce hex strings in signer backend for sign message
|
||||||
* 0.4.11
|
* 0.4.11
|
||||||
|
@ -17,10 +17,10 @@ from crypto_dev_signer.eth.transaction import EIP155Transaction
|
|||||||
from crypto_dev_signer.keystore import ReferenceKeystore
|
from crypto_dev_signer.keystore import ReferenceKeystore
|
||||||
from crypto_dev_signer.error import UnknownAccountError
|
from crypto_dev_signer.error import UnknownAccountError
|
||||||
|
|
||||||
#logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
|
|
||||||
config_dir = os.path.join('/usr/local/etc/cic-eth')
|
config_dir = '.'
|
||||||
|
|
||||||
db = None
|
db = None
|
||||||
signer = None
|
signer = None
|
||||||
@ -165,7 +165,14 @@ def process_input(j):
|
|||||||
return (rpc_id, methods[m](p))
|
return (rpc_id, methods[m](p))
|
||||||
|
|
||||||
|
|
||||||
def start_server():
|
def start_server_lo(spec):
|
||||||
|
s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||||
|
s.bind(spec)
|
||||||
|
logg.debug('created tcp socket {}'.format(spec))
|
||||||
|
start_server(s)
|
||||||
|
|
||||||
|
|
||||||
|
def start_server_ipc(socket_path):
|
||||||
socket_dir = os.path.dirname(socket_path)
|
socket_dir = os.path.dirname(socket_path)
|
||||||
try:
|
try:
|
||||||
fi = os.stat(socket_dir)
|
fi = os.stat(socket_dir)
|
||||||
@ -180,7 +187,12 @@ def start_server():
|
|||||||
pass
|
pass
|
||||||
s = socket.socket(family = socket.AF_UNIX, type = socket.SOCK_STREAM)
|
s = socket.socket(family = socket.AF_UNIX, type = socket.SOCK_STREAM)
|
||||||
s.bind(socket_path)
|
s.bind(socket_path)
|
||||||
|
logg.debug('created unix ipc socket {}'.format(socket_path))
|
||||||
|
start_server(s)
|
||||||
|
|
||||||
|
def start_server(s):
|
||||||
s.listen(10)
|
s.listen(10)
|
||||||
|
logg.debug('server started')
|
||||||
while True:
|
while True:
|
||||||
(csock, caddr) = s.accept()
|
(csock, caddr) = s.accept()
|
||||||
d = csock.recv(4096)
|
d = csock.recv(4096)
|
||||||
@ -235,7 +247,13 @@ def main():
|
|||||||
arg = json.loads(sys.argv[1])
|
arg = json.loads(sys.argv[1])
|
||||||
except:
|
except:
|
||||||
logg.info('no json rpc command detected, starting socket server')
|
logg.info('no json rpc command detected, starting socket server')
|
||||||
start_server()
|
socket_spec = socket_path.split(':')
|
||||||
|
if len(socket_spec) == 2:
|
||||||
|
host = socket_spec[0]
|
||||||
|
port = int(socket_spec[1])
|
||||||
|
start_server_lo((host, port))
|
||||||
|
else:
|
||||||
|
start_server_ipc(socket_path)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
(rpc_id, response) = process_input(arg)
|
(rpc_id, response) = process_input(arg)
|
||||||
|
2
setup.py
2
setup.py
@ -24,7 +24,7 @@ f.close()
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="crypto-dev-signer",
|
name="crypto-dev-signer",
|
||||||
version="0.4.13b10",
|
version="0.4.13b11",
|
||||||
description="A signer and keystore daemon and library for cryptocurrency software development",
|
description="A signer and keystore daemon and library for cryptocurrency software development",
|
||||||
author="Louis Holbrook",
|
author="Louis Holbrook",
|
||||||
author_email="dev@holbrook.no",
|
author_email="dev@holbrook.no",
|
||||||
|
Loading…
Reference in New Issue
Block a user