Testing zmq PUB/SUB for objects. Enabled by --msg-queue arg.

This commit is contained in:
Dmitri Bogomolov 2021-03-07 21:38:36 +02:00 committed by Lee Miller
parent ddf07fd506
commit 3c56afc570
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
3 changed files with 12 additions and 0 deletions

View File

@ -405,6 +405,9 @@ class Connection(threading.Thread):
logging.debug(dest)
shared.i2p_unchecked_node_pool.add((dest, 'i2p'))
shared.vector_advertise_queue.put(obj.vector)
if shared.zmq_socket:
shared.zmq_socket.send(
b'obj\x00%i\x00' % obj.object_type + obj.to_bytes())
elif m.command == b'getdata':
getdata = message.GetData.from_message(m)

View File

@ -42,6 +42,8 @@ def parse_arguments():
'--trusted-peer', help='Specify a trusted peer we should connect to')
parser.add_argument(
'--connection-limit', type=int, help='Maximum number of connections')
parser.add_argument(
'--msg-queue', action='store_true', help='Enable messages queue')
parser.add_argument(
'--i2p', action='store_true', help='Enable I2P support (uses SAMv3)')
parser.add_argument(
@ -90,6 +92,11 @@ def parse_arguments():
shared.trusted_peer = (addr[0], int(addr[1]))
if args.connection_limit:
shared.connection_limit = args.connection_limit
if args.msg_queue:
import zmq
zmq_context = zmq.Context()
shared.zmq_socket = zmq_context.socket(zmq.PUB)
shared.zmq_socket.bind("tcp://*:5556")
if args.i2p:
shared.i2p_enabled = True
if args.i2p_tunnel_length:

View File

@ -64,3 +64,5 @@ connection_limit = 250
objects = {}
objects_lock = threading.Lock()
zmq_socket = None