improve miner network functionality
This commit is contained in:
@@ -48,6 +48,7 @@ class MinerNetwork:
|
|||||||
if mask.startswith("/"):
|
if mask.startswith("/"):
|
||||||
mask = mask.replace("/", "")
|
mask = mask.replace("/", "")
|
||||||
self.mask = mask
|
self.mask = mask
|
||||||
|
self.network = self.get_network()
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len([item for item in self.get_network().hosts()])
|
return len([item for item in self.get_network().hosts()])
|
||||||
@@ -55,6 +56,10 @@ class MinerNetwork:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return str(self.network)
|
return str(self.network)
|
||||||
|
|
||||||
|
def hosts(self):
|
||||||
|
for x in self.network.hosts():
|
||||||
|
yield x
|
||||||
|
|
||||||
def get_network(self) -> ipaddress.ip_network:
|
def get_network(self) -> ipaddress.ip_network:
|
||||||
"""Get the network using the information passed to the MinerNetwork or from cache.
|
"""Get the network using the information passed to the MinerNetwork or from cache.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user