mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
* refactored : host_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored : network_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored : notifee_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored : net_connection_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored: raw_connection_interface, secure_conn_interface and stream_muxer abc.py * refactored: addrbook_interface * refactored :peerdata_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :peermetadata_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :multiselect_client_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :multiselect_communicator_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :multiselect_muxer_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :interfaces Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :security_transport_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * refactored :listener_interface Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * moved all interfaces and typing files Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> * fixed documentation and moved pubsub abc.py Co-authored-by: Khwahish Patel <khwahish.p1@ahduni.edu.in> * added exclude-members in custom_types docs * added : newsfragment for moving all interfaces to libp2p.abc --------- Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com> Co-authored-by: Mystical <125946525+mystical-prog@users.noreply.github.com>
54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
from typing import (
|
|
Optional,
|
|
)
|
|
|
|
from libp2p.abc import (
|
|
ISecureConn,
|
|
)
|
|
from libp2p.crypto.keys import (
|
|
PrivateKey,
|
|
PublicKey,
|
|
)
|
|
from libp2p.peer.id import (
|
|
ID,
|
|
)
|
|
|
|
|
|
class BaseSession(ISecureConn):
|
|
"""
|
|
``BaseSession`` is not fully instantiated from its abstract classes as
|
|
it is only meant to be used in clases that derive from it.
|
|
"""
|
|
|
|
local_peer: ID
|
|
local_private_key: PrivateKey
|
|
remote_peer: ID
|
|
remote_permanent_pubkey: PublicKey
|
|
|
|
def __init__(
|
|
self,
|
|
*,
|
|
local_peer: ID,
|
|
local_private_key: PrivateKey,
|
|
remote_peer: ID,
|
|
remote_permanent_pubkey: PublicKey,
|
|
is_initiator: bool,
|
|
) -> None:
|
|
self.local_peer = local_peer
|
|
self.local_private_key = local_private_key
|
|
self.remote_peer = remote_peer
|
|
self.remote_permanent_pubkey = remote_permanent_pubkey
|
|
self.is_initiator = is_initiator
|
|
|
|
def get_local_peer(self) -> ID:
|
|
return self.local_peer
|
|
|
|
def get_local_private_key(self) -> PrivateKey:
|
|
return self.local_private_key
|
|
|
|
def get_remote_peer(self) -> ID:
|
|
return self.remote_peer
|
|
|
|
def get_remote_public_key(self) -> Optional[PublicKey]:
|
|
return self.remote_permanent_pubkey
|