Apply PR feedback

This commit is contained in:
NIC619 2019-09-15 15:09:58 +08:00
parent 501513b747
commit f368f5e93b
No known key found for this signature in database
GPG Key ID: 570C35F5C2D51B17

View File

@ -126,10 +126,10 @@ class Swarm(INetwork):
try:
secured_conn = await self.upgrader.upgrade_security(raw_conn, peer_id, True)
except SecurityUpgradeFailure as error:
error_msg = "fail to upgrade security for peer %s" % peer_id
logger.debug(error_msg)
error_msg = "fail to upgrade security for peer %s"
logger.debug(error_msg, peer_id)
await raw_conn.close()
raise SwarmException(error_msg) from error
raise SwarmException(error_msg % peer_id) from error
logger.debug("upgraded security for peer %s", peer_id)
@ -138,10 +138,10 @@ class Swarm(INetwork):
secured_conn, self.generic_protocol_handler, peer_id
)
except MuxerUpgradeFailure as error:
error_msg = "fail to upgrade mux for peer %s" % peer_id
logger.debug(error_msg)
error_msg = "fail to upgrade mux for peer %s"
logger.debug(error_msg, peer_id)
await secured_conn.close()
raise SwarmException(error_msg) from error
raise SwarmException(error_msg % peer_id) from error
logger.debug("upgraded mux for peer %s", peer_id)
@ -232,10 +232,10 @@ class Swarm(INetwork):
raw_conn, ID(b""), False
)
except SecurityUpgradeFailure as error:
error_msg = "fail to upgrade security for peer at %s" % peer_addr
logger.debug(error_msg)
error_msg = "fail to upgrade security for peer at %s"
logger.debug(error_msg, peer_addr)
await raw_conn.close()
raise SwarmException(error_msg) from error
raise SwarmException(error_msg % peer_addr) from error
peer_id = secured_conn.get_remote_peer()
logger.debug("upgraded security for peer at %s", peer_addr)
@ -246,10 +246,10 @@ class Swarm(INetwork):
secured_conn, self.generic_protocol_handler, peer_id
)
except MuxerUpgradeFailure as error:
error_msg = "fail to upgrade mux for peer %s" % peer_id
logger.debug(error_msg)
error_msg = "fail to upgrade mux for peer %s"
logger.debug(error_msg, peer_id)
await secured_conn.close()
raise SwarmException(error_msg) from error
raise SwarmException(error_msg % peer_id) from error
logger.debug("upgraded mux for peer %s", peer_id)
# Store muxed_conn with peer id
self.connections[peer_id] = muxed_conn