Skip to content

Commit

Permalink
Do parallel confirm_req
Browse files Browse the repository at this point in the history
  • Loading branch information
dsiganos committed Feb 29, 2024
1 parent 0334b49 commit ff95ce0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions confirm_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
import argparse
import datetime
import multiprocessing

import common
import constants
Expand Down Expand Up @@ -241,6 +242,7 @@ def confirm_blocks_by_hash(ctx: dict, pairs: list[hash_pair], s: socket.socket)


def confirm_req_peer(ctx: dict, pair: hash_pair, peeraddr: str = None, peerport: int = None) -> bool:
print('Connecting to [%s]:%s' % (peeraddr, peerport))
assert pair is not None
with get_connected_socket_endpoint(peeraddr, peerport) as s:
signing_key, verifying_key = node_handshake_id.keypair()
Expand Down Expand Up @@ -286,8 +288,12 @@ def main() -> None:
peeraddr = str(peer.ip)
peerport = peer.port

print('Connecting to [%s]:%s' % (peeraddr, peerport))
confirm_req_peer(ctx, pair, peeraddr=peeraddr, peerport=peerport)
pool_args = [(ctx, pair, peeraddr, peerport)] * 10
pool = multiprocessing.Pool(processes=10)
results = pool.starmap(confirm_req_peer, pool_args)
pool.close()
pool.join()
print(results)


def parse_args():
Expand Down

0 comments on commit ff95ce0

Please sign in to comment.