예제 #1
0
        public NodePersister(IActorRef blockchain, string connectionString, string net, RPCNodeCaller nodeCaller)
        {
            this.connectionString = connectionString;
            this.net             = net;
            this.nodeCaller      = nodeCaller;
            this.NodesAuditCache = new Dictionary <string, Dictionary <int, ICollection <long> > >();

            blockchain.Tell(new Register());
        }
예제 #2
0
        public NodePersister(string connectionString, string net, RPCNodeCaller nodeCaller)
        {
            this.connectionString = connectionString;
            this.net             = net;
            this.nodeCaller      = nodeCaller;
            this.NodesAuditCache = new Dictionary <string, Dictionary <int, ICollection <long> > >();

            Context.System.EventStream.Subscribe(Self, typeof(Blockchain.PersistCompleted));
        }
예제 #3
0
 public static Props Props(IActorRef blockchain, string connectionString, string net, RPCNodeCaller nodeCaller) =>
 Akka.Actor.Props.Create(() => new NodePersister(blockchain, connectionString, net, nodeCaller));
예제 #4
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();
        }