def __init__( self, port: int, api: Any, local_type: NodeType, ping_interval: int, network_id: str, root_path: Path, config: Dict, name: str = None, ): # Keeps track of all connections to and from this node. self.global_connections: PeerConnections = PeerConnections([]) self._port = port # TCP port to identify our node self._local_type = local_type # NodeType (farmer, full node, timelord, pool, harvester, wallet) self._ping_interval = ping_interval # (StreamReader, StreamWriter, NodeType) aiter, gets things from server and clients and # sends them through the pipeline self._srwt_aiter: push_aiter = push_aiter() # Aiter used to broadcase messages self._outbound_aiter: push_aiter = push_aiter() # Taks list to keep references to tasks, so they don'y get GCd self._tasks: List[asyncio.Task] = [] if local_type != NodeType.INTRODUCER: # Introducers should not keep connections alive, they should close them self._tasks.append(self._initialize_ping_task()) if name: self.log = logging.getLogger(name) else: self.log = logging.getLogger(__name__) # Our unique random node id that we will send to other peers, regenerated on launch node_id = create_node_id() if hasattr(api, "_set_global_connections"): api._set_global_connections(self.global_connections) # Tasks for entire server pipeline self._pipeline_task: asyncio.Future = asyncio.ensure_future( initialize_pipeline( self._srwt_aiter, api, self._port, self._outbound_aiter, self.global_connections, self._local_type, node_id, network_id, self.log, ) ) self.root_path = root_path self.config = config
def __init__(self, port: int, api: Any, local_type: NodeType): self._port = port # TCP port to identify our node self._api = api # API module that will be called from the requests self._local_type = local_type # NodeType (farmer, full node, timelord, pool, harvester, wallet) self._srwt_aiter = push_aiter() self._outbound_aiter = push_aiter() self._pipeline_task = self.initialize_pipeline(self._srwt_aiter, self._api, self._port) self._ping_task = self._initialize_ping_task() self._node_id = create_node_id()
def __init__( self, port: int, api: Any, local_type: NodeType, ping_interval: int, network_id: str, root_path: Path, config: Dict, name: str = None, ): # Keeps track of all connections to and from this node. self.global_connections: PeerConnections = PeerConnections([]) # Optional listening server. You can also use this class without starting one. self._server: Optional[asyncio.AbstractServer] = None # Called for inbound connections after successful handshake self._on_inbound_connect: OnConnectFunc = None self._port = port # TCP port to identify our node self._api = api # API module that will be called from the requests self._local_type = local_type # NodeType (farmer, full node, timelord, pool, harvester, wallet) self._ping_interval = ping_interval self._network_id = network_id # (StreamReader, StreamWriter, NodeType) aiter, gets things from server and clients and # sends them through the pipeline self._srwt_aiter: push_aiter = push_aiter() # Aiter used to broadcase messages self._outbound_aiter: push_aiter = push_aiter() # Tasks for entire server pipeline self._pipeline_task: asyncio.Task = self.initialize_pipeline( self._srwt_aiter, self._api, self._port) # Our unique random node id that we will other peers, regenerated on launch self._node_id = create_node_id() # Taks list to keep references to tasks, so they don'y get GCd self._tasks: List[asyncio.Task] = [self._initialize_ping_task()] if name: self.log = logging.getLogger(name) else: self.log = logging.getLogger(__name__) self.root_path = root_path self.config = config