コード例 #1
0
ファイル: node.py プロジェクト: cryptobi/avax-python
    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()
コード例 #2
0
ファイル: Packer.py プロジェクト: cryptobi/avax-python
    def UnpackIP(self):
        ipbytes = self.UnpackFixedBytes(16)
        ipa = None
        if ipbytes[-6] == 0xff and ipbytes[-5] == 0xff:
            ipa = ipaddress.IPv4Address(ipbytes[-4:])
        else:
            ipa = ipaddress.IPv6Address(ipbytes)

        port = self.UnpackShort()
        return IPDesc(IP=str(ipa), Port=port)
コード例 #3
0
ファイル: Packer.py プロジェクト: cryptobi/avax-python
    def PackIP(self, ip: IPDesc):
        ipto16_a = ip.To16()

        barr = bytearray(ipto16_a)
        if ip.version == IPDesc.V4:
            barr[-6] = 0xff
            barr[-5] = 0xff

        ipto16 = bytes(barr)

        self.PackFixedBytes(ipto16)
        self.PackShort(ip.Port)
コード例 #4
0
from avaxpython.utils.ip import IPDesc
from avaxpython.node.node import Node
from avaxpython.node.Config import Config as NodeConfig
from avaxpython.network.handlers.HostLister import HostLister

node_config = NodeConfig()

avaxpython.config().set("log_level", logging.ERROR)

logger = avaxpython.config().logger()

hl = HostLister()
avaxpython.config().set("network_handler", hl)

stk_ip = ip.get_internal_ip()
node_config.StakingIP = IPDesc(stk_ip.ip, NodeConfig.STAKING_PORT)

node = Node()


def signal_handler(sig, frame):
    logger.info("Stopping the AVAX node.")
    node.Shutdown()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)

node.Initialize(node_config)
node.Dispatch()
コード例 #5
0
    sys.exit(0)


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()
コード例 #6
0
 def __init__(self) -> None:        
     self.Cert: Certificate = Certificate()
     self.IPDesc = IPDesc()
     self.Time = Uint64()
     self.Signature = Bytes()