Skip to content
Snippets Groups Projects
remoteconnection.py 637 B
Newer Older
  • Learn to ignore specific revisions
  • import ipaddress
    import time
    
    
    class RemoteConnection:
    
        def __init__(self, ip: ipaddress.IPv4Address, pk: bytes, cap: float, ucap: float, l: float):
    
            self.publicIP: ipaddress.IPv4Address = ip
            self.publicKey: bytes = pk
    
            self.availableCapacity: float = cap
            self.usedCapacity: float = ucap
    
            self.loss = l  # loss rate during transmission or transformation
    
            self.timestamp = time.time_ns()
    
    
        def __eq__(self, other):
            return self.publicKey == other.publicKey
    
        def __hash__(self):
            return hash(self.publicKey)
    
    
        def __str__(self):
            return self.publicIP.__str__()