Пример #1
0
        public void Init()
        {
            Logger             = Services.GetService <ILogger>();
            _blockChainService = Services.GetService <IBlockChainService>();
            _catchUpService    = Services.GetService <ICatchUpService>();
            ToParseQueue       = new Queue <Action>();
            var parser = new Thread(new ThreadStart(ParserThread));

            parser.Start();
            Start();
        }
Пример #2
0
        public void Init()
        {
            externalIp = JsonConvert.DeserializeObject <IpJson>(new WebClient().DownloadString("https://api.ipify.org/?format=json")).Ip;

            _peersFullPath   = Configurations.CurrentPath + "\\BlockChain\\Data\\Peers.json";
            _originsFullPath = Configurations.CurrentPath + "\\BlockChain\\Data\\Origins.json";

            ThisPeer = new Peer()
            {
                Address = externalIp, Port = Configurations.Config.MainPort
            };
            RequestHeader.Me = ThisPeer;

            ActiveRequestForPeers = new List <RequestForPeers>();

            _server    = Services.GetService <IP2PServer>();
            _catcherUp = Services.GetService <ICatchUpService>();

            Logger = Services.GetService <ILogger>();


            TryLoadPeers();
            Task.Run(() => PeerUpdateLoop());

            Peers.CollectionChanged += Peers_CollectionChanged;

            try
            {
                DoUPnP().Wait();
                Logger.Log("NAT traversal successfull.");
            }
            catch (Exception ex)
            {
                Logger.Log("UPnP NAT traversal error: " + ex.Message + " || " + ex.StackTrace, 2);
            }
        }