private void ServerForm_Shown(object sender, EventArgs e) { TitleFormat = Text; UpdateEmpNum(0); ListenWorker.RunWorkerAsync(); Console.WriteLine("Worker started..."); }
public LocalClient(ChainType type, IKernel kernel, CoreDaemon coreDaemon, INetworkPeerStorage networkPeerStorage) { this.shutdownToken = new CancellationTokenSource(); this.type = type; this.kernel = kernel; this.coreDaemon = coreDaemon; this.chainParams = coreDaemon.ChainParams; this.coreStorage = coreDaemon.CoreStorage; this.networkPeerStorage = networkPeerStorage; this.messageRateMeasure = new RateMeasure(); this.headersRequestWorker = new HeadersRequestWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromMilliseconds(50), maxIdleTime: TimeSpan.FromSeconds(5)), this, this.coreDaemon); this.blockRequestWorker = new BlockRequestWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromMilliseconds(50), maxIdleTime: TimeSpan.FromSeconds(30)), this, this.coreDaemon); this.peerWorker = new PeerWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromSeconds(1), maxIdleTime: TimeSpan.FromSeconds(1)), this, this.coreDaemon, this.headersRequestWorker); this.listenWorker = new ListenWorker(this, this.peerWorker); this.statsWorker = new WorkerMethod("LocalClient.StatsWorker", StatsWorker, true, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(5)); this.peerWorker.PeerHandshakeCompleted += HandlePeerHandshakeCompleted; this.peerWorker.PeerDisconnected += HandlePeerDisconnected; this.blockRequestWorker.OnBlockFlushed += HandleBlockFlushed; switch (this.Type) { case ChainType.MainNet: Messaging.Port = 8333; Messaging.Magic = Messaging.MAGIC_MAIN; break; case ChainType.TestNet3: Messaging.Port = 18333; Messaging.Magic = Messaging.MAGIC_TESTNET3; break; case ChainType.Regtest: Messaging.Port = 18444; Messaging.Magic = Messaging.MAGIC_COMPARISON_TOOL; break; } }
public LocalClient(Logger logger, RulesEnum type, IKernel kernel, IBlockchainRules rules, CoreDaemon coreDaemon, NetworkPeerCache networkPeerCache) { this.shutdownToken = new CancellationTokenSource(); this.logger = logger; this.type = type; this.kernel = kernel; this.rules = rules; this.coreDaemon = coreDaemon; this.coreStorage = coreDaemon.CoreStorage; this.networkPeerCache = networkPeerCache; this.messageRateMeasure = new RateMeasure(); this.peerWorker = new PeerWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromSeconds(1), maxIdleTime: TimeSpan.FromSeconds(1)), this.logger, this, this.coreDaemon); this.listenWorker = new ListenWorker(this.logger, this, this.peerWorker); this.headersRequestWorker = new HeadersRequestWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromMilliseconds(50), maxIdleTime: TimeSpan.FromSeconds(5)), this.logger, this, this.coreDaemon); this.blockRequestWorker = new BlockRequestWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromMilliseconds(50), maxIdleTime: TimeSpan.FromSeconds(30)), this.logger, this, this.coreDaemon); this.statsWorker = new WorkerMethod("LocalClient.StatsWorker", StatsWorker, true, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30), this.logger); this.peerWorker.PeerConnected += HandlePeerConnected; this.peerWorker.PeerDisconnected += HandlePeerDisconnected; switch (this.Type) { case RulesEnum.MainNet: Messaging.Port = 8333; Messaging.Magic = Messaging.MAGIC_MAIN; break; case RulesEnum.TestNet3: Messaging.Port = 18333; Messaging.Magic = Messaging.MAGIC_TESTNET3; break; case RulesEnum.ComparisonToolTestNet: Messaging.Port = 18444; Messaging.Magic = Messaging.MAGIC_COMPARISON_TOOL; break; } }