mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
merge bitcoin#29356: make v2transport arg in addconnection mandatory and few cleanups
This commit is contained in:
parent
c53cd93aee
commit
3c1636174b
@ -360,7 +360,7 @@ static RPCHelpMan addconnection()
|
|||||||
{
|
{
|
||||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address and port to attempt connecting to."},
|
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address and port to attempt connecting to."},
|
||||||
{"connection_type", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of connection to open (\"outbound-full-relay\", \"block-relay-only\", \"addr-fetch\" or \"feeler\")."},
|
{"connection_type", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of connection to open (\"outbound-full-relay\", \"block-relay-only\", \"addr-fetch\" or \"feeler\")."},
|
||||||
{"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol"},
|
{"v2transport", RPCArg::Type::BOOL, RPCArg::Optional::NO, "Attempt to connect using BIP324 v2 transport protocol"},
|
||||||
},
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
RPCResult::Type::OBJ, "", "",
|
RPCResult::Type::OBJ, "", "",
|
||||||
|
@ -100,7 +100,7 @@ class AnchorsTest(BitcoinTestFramework):
|
|||||||
self.restart_node(0, extra_args=[f"-onion={onion_conf.addr[0]}:{onion_conf.addr[1]}"])
|
self.restart_node(0, extra_args=[f"-onion={onion_conf.addr[0]}:{onion_conf.addr[1]}"])
|
||||||
|
|
||||||
self.log.info("Add 256-bit-address block-relay-only connections to node")
|
self.log.info("Add 256-bit-address block-relay-only connections to node")
|
||||||
self.nodes[0].addconnection(ONION_ADDR, 'block-relay-only')
|
self.nodes[0].addconnection(ONION_ADDR, 'block-relay-only', v2transport=False)
|
||||||
|
|
||||||
self.log.debug("Stop node")
|
self.log.debug("Stop node")
|
||||||
with self.nodes[0].assert_debug_log([f"DumpAnchors: Flush 1 outbound block-relay-only peer addresses to anchors.dat"]):
|
with self.nodes[0].assert_debug_log([f"DumpAnchors: Flush 1 outbound block-relay-only peer addresses to anchors.dat"]):
|
||||||
|
@ -272,7 +272,7 @@ class P2PConnection(asyncio.Protocol):
|
|||||||
self.on_close()
|
self.on_close()
|
||||||
|
|
||||||
# v2 handshake method
|
# v2 handshake method
|
||||||
def v2_handshake(self):
|
def _on_data_v2_handshake(self):
|
||||||
"""v2 handshake performed before P2P messages are exchanged (see BIP324). P2PConnection is the initiator
|
"""v2 handshake performed before P2P messages are exchanged (see BIP324). P2PConnection is the initiator
|
||||||
(in inbound connections to TestNode) and the responder (in outbound connections from TestNode).
|
(in inbound connections to TestNode) and the responder (in outbound connections from TestNode).
|
||||||
Performed by:
|
Performed by:
|
||||||
@ -325,7 +325,7 @@ class P2PConnection(asyncio.Protocol):
|
|||||||
if len(t) > 0:
|
if len(t) > 0:
|
||||||
self.recvbuf += t
|
self.recvbuf += t
|
||||||
if self.supports_v2_p2p and not self.v2_state.tried_v2_handshake:
|
if self.supports_v2_p2p and not self.v2_state.tried_v2_handshake:
|
||||||
self.v2_handshake()
|
self._on_data_v2_handshake()
|
||||||
else:
|
else:
|
||||||
self._on_data()
|
self._on_data()
|
||||||
|
|
||||||
@ -631,9 +631,7 @@ class P2PInterface(P2PConnection):
|
|||||||
|
|
||||||
def wait_for_reconnect(self, timeout=60):
|
def wait_for_reconnect(self, timeout=60):
|
||||||
def test_function():
|
def test_function():
|
||||||
if not (self.is_connected and self.last_message.get('version') and self.v2_state is None):
|
return self.is_connected and self.last_message.get('version') and not self.supports_v2_p2p
|
||||||
return False
|
|
||||||
return True
|
|
||||||
self.wait_until(test_function, timeout=timeout, check_connected=False)
|
self.wait_until(test_function, timeout=timeout, check_connected=False)
|
||||||
|
|
||||||
# Message receiving helper methods
|
# Message receiving helper methods
|
||||||
|
@ -259,6 +259,7 @@ class EncryptedP2PState:
|
|||||||
# decoy packets have contents = None. v2 handshake is complete only when version packet
|
# decoy packets have contents = None. v2 handshake is complete only when version packet
|
||||||
# (can be empty with contents = b"") with contents != None is received.
|
# (can be empty with contents = b"") with contents != None is received.
|
||||||
if contents is not None:
|
if contents is not None:
|
||||||
|
assert contents == b"" # currently TestNode sends an empty version packet
|
||||||
self.tried_v2_handshake = True
|
self.tried_v2_handshake = True
|
||||||
return processed_length, True
|
return processed_length, True
|
||||||
response = response[length:]
|
response = response[length:]
|
||||||
|
Loading…
Reference in New Issue
Block a user