chia-blockchain/chia/util/network.py

34 lines
1.0 KiB
Python
Raw Normal View History

from chia.server.outbound_message import NodeType
2020-10-28 20:45:10 +03:00
def is_localhost(peer_host: str):
return peer_host == "127.0.0.1" or peer_host == "localhost" or peer_host == "::1" or peer_host == "0:0:0:0:0:0:0:1"
2020-10-28 20:45:10 +03:00
def class_for_type(type: NodeType):
if type is NodeType.FULL_NODE:
from chia.full_node.full_node_api import FullNodeAPI
2020-10-28 20:45:10 +03:00
return FullNodeAPI
elif type is NodeType.WALLET:
from chia.wallet.wallet_node_api import WalletNodeAPI
2020-10-28 20:45:10 +03:00
return WalletNodeAPI
elif type is NodeType.INTRODUCER:
from chia.introducer.introducer_api import IntroducerAPI
2020-10-28 20:45:10 +03:00
return IntroducerAPI
elif type is NodeType.TIMELORD:
from chia.timelord.timelord_api import TimelordAPI
2020-10-28 20:45:10 +03:00
return TimelordAPI
elif type is NodeType.FARMER:
from chia.farmer.farmer_api import FarmerAPI
2020-10-28 20:45:10 +03:00
return FarmerAPI
elif type is NodeType.HARVESTER:
from chia.harvester.harvester_api import HarvesterAPI
2020-10-28 20:45:10 +03:00
return HarvesterAPI
raise ValueError("No class for type")