def Dispatch(self): for i in range(len(beacons.beacon_ips[constants.MainnetID])): beacon_hp = beacons.beacon_ips[constants.MainnetID][i] beacon_id = beacons.beacon_ids[constants.MainnetID][i] host_addr, host_port = beacon_hp.split(":") p = Peer(self.Net, conn=None, ip=IPDesc(host_addr, int(host_port)), port=int(host_port), node=self, my_staking_ip=self.Config.StakingIP) self.Config.BootstrapPeers.append(p) random.shuffle(self.Config.BootstrapPeers) for peer in self.Config.BootstrapPeers: if peer.ip.IP != self.Config.StakingIP.IP: self.Net.track(peer) else: self.Log.Error("can't add self as a bootstrapper") self.Net.Dispatch() # If the P2P server isn't running, shut down the node. # If node is already shutting down, this does nothing. self.Shutdown() # Wait until the node is done shutting down before returning self.doneShuttingDown.Wait()
def __init__(self) -> None: # the peer, if it wasn't a peer when we cloned the list this value will be # nil self.peer = Peer() # this is the validator id for the peer, we pass back to the caller for # logging purposes self.id = ShortID()
signal.signal(signal.SIGINT, sigint_handler) params.parseCmdLine() node_config = params.Config avaxpython.config().set("handler", DefaultHandler()) avax_handler = AVAXHandler() network = Network(router=ChainRouter()) network.nodeID = random.randint(9999, 4294967295) peer = Peer(network, DummyConnection(), IPDesc('127.0.0.1', 9651), None, 0, None, None, my_staking_ip=IPDesc('127.0.0.1', 9651)) chainManager = ChainManager() dummy_node_id = ShortID() vmManager = VMManager() chain_configs.VMManager = vmManager vdrs = ValidatorsManager() chainManager = ChainManager() chainManager.config.VMManager = vmManager chainManager.config.Validators = vdrs