コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              StateOfNeoSeedData seeder,
                              NotificationEngine notificationEngine)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            // Shows UseCors with CorsPolicyBuilder.
            app.UseCors(builder =>
            {
                builder
                .WithOrigins("http://localhost:8111", "http://localhost:4200")
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials();
            });

            app.UseStaticFiles();

            app.UseSignalR(routes =>
            {
                routes.MapHub <BlockHub>("/hubs/block");
                routes.MapHub <NodeHub>("/hubs/node");
                routes.MapHub <TransactionCountHub>("/hubs/trans-count");
                routes.MapHub <TransactionAverageCountHub>("/hubs/trans-average-count");
                routes.MapHub <FailedP2PHub>("/hubs/fail-p2p");
            });

            //app.UseHttpsRedirection();
            seeder.Init();

            notificationEngine.Init();

            app.UseMvc();
        }
コード例 #2
0
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            SmartContractEngine smartContractEngine,
            StateOfNeoSeedData seeder,
            StateOfNeoContext ctx,
            IServiceProvider services,
            IOptions <NetSettings> netSettings,
            IOptions <ImportBlocksSettings> importSettings,
            IHubContext <StatsHub> statsHub,
            IHubContext <PeersHub> peersHub,
            IHubContext <TransactionsHub> txHub,
            IHubContext <NotificationHub> notificationHub,
            BlockchainBalances blockChainBalances,
            RPCNodeCaller nodeCaller,
            NodeCache nodeCache,
            IStateService state
            )
        {
            nodeCache.AddPeerToCache(ctx.Peers.ToList());
            var connectionString = this.Configuration.GetConnectionString("DefaultConnection");

            Program.NeoSystem.ActorSystem.ActorOf(BlockPersister.Props(
                                                      Program.NeoSystem.Blockchain,
                                                      connectionString,
                                                      state,
                                                      statsHub,
                                                      txHub,
                                                      notificationHub,
                                                      blockChainBalances,
                                                      netSettings.Value.Net));

            Program.NeoSystem.ActorSystem.ActorOf(NodePersister.Props(
                                                      Program.NeoSystem.Blockchain,
                                                      connectionString,
                                                      netSettings.Value.Net,
                                                      nodeCaller));

            Program.NeoSystem.ActorSystem.ActorOf(NodeFinder.Props(
                                                      Program.NeoSystem.Blockchain,
                                                      connectionString,
                                                      netSettings.Value,
                                                      peersHub,
                                                      nodeCache));

            //    Program.NeoSystem.ActorSystem.ActorOf(NotificationsListener.Props(Program.NeoSystem.Blockchain, connectionString));

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseCors(builder =>
            {
                builder
                .WithOrigins("http://localhost:8111", "http://localhost:4200")
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials();
            });

            app.UseStaticFiles();

            app.UseSignalR(routes =>
            {
                routes.MapHub <StatsHub>("/hubs/stats");
                routes.MapHub <TransactionsHub>("/hubs/tx");
                routes.MapHub <PeersHub>("/hubs/peers");
                routes.MapHub <NotificationHub>("/hubs/notification");
            });

            Task.Run(() => smartContractEngine.Run());

            seeder.Init();

            app.UseMvc();
        }