示例#1
0
 public StateStore(NeoSystem core, string path)
 {
     if (singleton != null)
     {
         throw new InvalidOperationException(nameof(StateStore));
     }
     this.core  = core;
     this.store = core.LoadStore(path);
     singleton  = this;
     core.ActorSystem.EventStream.Subscribe(Self, typeof(Blockchain.RelayResult));
     UpdateCurrentSnapshot();
 }
        protected override void OnSystemLoaded(NeoSystem system)
        {
            if (system.Settings.Network != Settings.Default.Network)
            {
                return;
            }
            store      = system.LoadStore(string.Format(Settings.Default.DBPath, Settings.Default.Network.ToString("X8")));
            controller = new RosettaController(system, store);
            var dflt = Settings.Default;

            host = new WebHostBuilder().UseKestrel(options => options.Listen(dflt.BindAddress, dflt.Port, listenOptions =>
            {
                // default is unlimited
                options.Limits.MaxConcurrentConnections = 50;
                // default is 2 minutes
                options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(1);
                // default is 30 seconds
                options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(15);

                if (string.IsNullOrEmpty(dflt.SslCert))
                {
                    return;
                }
                listenOptions.UseHttps(dflt.SslCert, dflt.SslCertPassword, httpsConnectionAdapterOptions =>
                {
                    if (dflt.TrustedAuthorities is null || dflt.TrustedAuthorities.Length == 0)
                    {
                        return;
                    }
                    httpsConnectionAdapterOptions.ClientCertificateMode       = ClientCertificateMode.RequireCertificate;
                    httpsConnectionAdapterOptions.ClientCertificateValidation = (cert, chain, err) =>
                    {
                        if (err != SslPolicyErrors.None)
                        {
                            return(false);
                        }
                        X509Certificate2 authority = chain.ChainElements[chain.ChainElements.Count - 1].Certificate;
                        return(dflt.TrustedAuthorities.Contains(authority.Thumbprint));
                    };
                });
            }))
示例#3
0
 public void Start(Wallet wallet)
 {
     if (started)
     {
         return;
     }
     started   = true;
     consensus = System.ActorSystem.ActorOf(ConsensusService.Props(System.LocalNode, System.TaskManager, System.Blockchain, System.LoadStore(Settings.Default.RecoveryLogs), wallet));
     consensus.Tell(new ConsensusService.Start());
 }