@@ -1458,9 +1458,7 @@ class NodeConnCB():
1458
1458
"""Callback and helper functions for P2P connection to a bitcoind node.
1459
1459
1460
1460
Individual testcases should subclass this and override the on_* methods
1461
- if they want to alter message handling behaviour.
1462
- """
1463
-
1461
+ if they want to alter message handling behaviour."""
1464
1462
def __init__ (self ):
1465
1463
# Track whether we have a P2P connection open to the node
1466
1464
self .connected = False
@@ -1474,25 +1472,13 @@ def __init__(self):
1474
1472
# A count of the number of ping messages we've sent to the node
1475
1473
self .ping_counter = 1
1476
1474
1477
- # deliver_sleep_time is helpful for debugging race conditions in p2p
1478
- # tests; it causes message delivery to sleep for the specified time
1479
- # before acquiring the global lock and delivering the next message.
1480
- self .deliver_sleep_time = None
1481
-
1482
1475
# Message receiving methods
1483
1476
1484
1477
def deliver (self , conn , message ):
1485
1478
"""Receive message and dispatch message to appropriate callback.
1486
1479
1487
1480
We keep a count of how many of each message type has been received
1488
- and the most recent message of each type.
1489
-
1490
- Optionally waits for deliver_sleep_time before dispatching message.
1491
- """
1492
-
1493
- deliver_sleep = self .get_deliver_sleep_time ()
1494
- if deliver_sleep is not None :
1495
- time .sleep (deliver_sleep )
1481
+ and the most recent message of each type."""
1496
1482
with mininode_lock :
1497
1483
try :
1498
1484
command = message .command .decode ('ascii' )
@@ -1504,10 +1490,6 @@ def deliver(self, conn, message):
1504
1490
sys .exc_info ()[0 ]))
1505
1491
raise
1506
1492
1507
- def get_deliver_sleep_time (self ):
1508
- with mininode_lock :
1509
- return self .deliver_sleep_time
1510
-
1511
1493
# Callback methods. Can be overridden by subclasses in individual test
1512
1494
# cases to provide custom message handling behaviour.
1513
1495
@@ -1616,9 +1598,10 @@ def sync_with_ping(self, timeout=60):
1616
1598
wait_until (test_function , timeout = timeout , lock = mininode_lock )
1617
1599
self .ping_counter += 1
1618
1600
1619
- # The actual NodeConn class
1620
- # This class provides an interface for a p2p connection to a specified node
1621
1601
class NodeConn (asyncore .dispatcher ):
1602
+ """The actual NodeConn class
1603
+
1604
+ This class provides an interface for a p2p connection to a specified node."""
1622
1605
messagemap = {
1623
1606
b"version" : msg_version ,
1624
1607
b"verack" : msg_verack ,
@@ -1838,13 +1821,3 @@ def run(self):
1838
1821
[ obj .handle_close () for obj in disconnected ]
1839
1822
asyncore .loop (0.1 , use_poll = True , map = mininode_socket_map , count = 1 )
1840
1823
logger .debug ("Network thread closing" )
1841
-
1842
-
1843
- # An exception we can raise if we detect a potential disconnect
1844
- # (p2p or rpc) before the test is complete
1845
- class EarlyDisconnectError (Exception ):
1846
- def __init__ (self , value ):
1847
- self .value = value
1848
-
1849
- def __str__ (self ):
1850
- return repr (self .value )
0 commit comments