mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Apply PR feedback
This commit is contained in:
@ -99,15 +99,6 @@ class PrivateKey(Key):
|
||||
"""
|
||||
return self._serialize_to_protobuf().SerializeToString()
|
||||
|
||||
def _protobuf_from_serialization(self, data: bytes) -> protobuf.PrivateKey:
|
||||
"""
|
||||
Return the protobuf representation of this ``Key``.
|
||||
"""
|
||||
key_type = self.get_type().value
|
||||
data = self.to_bytes()
|
||||
protobuf_key = protobuf.PrivateKey(key_type=key_type, data=data)
|
||||
return protobuf_key
|
||||
|
||||
@classmethod
|
||||
def deserialize_from_protobuf(cls, protobuf_data: bytes) -> protobuf.PrivateKey:
|
||||
return protobuf.PrivateKey.FromString(protobuf_data)
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
class MsgioException(Exception):
|
||||
from libp2p.exceptions import BaseLibp2pError
|
||||
|
||||
|
||||
class MsgioException(BaseLibp2pError):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@ -350,14 +350,14 @@ async def create_secure_session(
|
||||
local_peer, local_private_key, remote_peer, conn, local_nonce
|
||||
)
|
||||
except SecioException as e:
|
||||
conn.close()
|
||||
await conn.close()
|
||||
raise e
|
||||
|
||||
session = _mk_session_from(local_private_key, session_parameters, conn)
|
||||
|
||||
received_nonce = await _finish_handshake(session, remote_nonce)
|
||||
if received_nonce != local_nonce:
|
||||
conn.close()
|
||||
await conn.close()
|
||||
raise HandshakeFailed()
|
||||
|
||||
return session
|
||||
|
||||
@ -99,7 +99,3 @@ async def test_create_secure_session():
|
||||
remote_pipe_task.cancel()
|
||||
await local_pipe_task
|
||||
await remote_pipe_task
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_create_secure_session())
|
||||
|
||||
Reference in New Issue
Block a user