Example #1
0
        public static async Task Main(string[] args)
        {
            try
            {
                Network network = args.Contains("-testnet")
                    ? NetworkRegistration.Register(new RedstoneTest())
                    : args.Contains("-regnet")
                    ? NetworkRegistration.Register(new RedstoneRegTest())
                    : NetworkRegistration.Register(new RedstoneMain());

                var nodeSettings = new NodeSettings(network: network, protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args.Concat(new[] { "-txIndex=1", "-addressIndex=1" }).ToArray())
                {
                    MinProtocolVersion = ProtocolVersion.ALT_PROTOCOL_VERSION
                };

                bool keyGenerationRequired = RequiresKeyGeneration(nodeSettings);
                if (keyGenerationRequired)
                {
                    GenerateServiceNodeKey(nodeSettings);
                    return;
                }

                var dnsSettings = new DnsSettings(nodeSettings);

                var isDns = !string.IsNullOrWhiteSpace(dnsSettings.DnsHostName) &&
                            !string.IsNullOrWhiteSpace(dnsSettings.DnsNameServer) &&
                            !string.IsNullOrWhiteSpace(dnsSettings.DnsMailBox);

                var builder = new FullNodeBuilder()
                              .UseNodeSettings(nodeSettings);

                if (isDns)
                {
                    // Run as a full node with DNS or just a DNS service?
                    if (dnsSettings.DnsFullNode)
                    {
                        builder = builder
                                  .UseBlockStore()
                                  .UseRedstonePosConsensus()
                                  .UseMempool()
                                  .UseWallet()
                                  .AddRedstoneMining();
                    }
                    else
                    {
                        builder = builder.UsePosConsensus();
                    }

                    builder = builder
                              .UseApi()
                              .AddRPC()
                              .UseDns();
                }
                else
                {
                    builder = builder
                              .UseBlockStore()
                              .UseRedstonePosConsensus()
                              .UseMempool()
                              .UseColdStakingWallet()
                              .AddRedstoneMining()
                              .UseApi()
                              .UseWatchOnlyWallet()
                              .UseBlockNotification()
                              .UseTransactionNotification()
                              .AddServiceNodeRegistration()
                              .UseApps()
                              .UseBlockExplorer()
                              .AddRPC();
                }

                var node = builder.Build();

                if (node != null)
                {
                    await node.RunAsync();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.ToString());
            }
        }
Example #2
0
        public static async Task Main(string[] args)
        {
            try
            {
                Network network = args.Contains("-testnet")
                    ? NetworkRegistration.Register(new RedstoneTest())
                    : args.Contains("-regnet")
                    ? NetworkRegistration.Register(new RedstoneRegTest())
                    : NetworkRegistration.Register(new RedstoneMain());

                var nodeSettings = new NodeSettings(network: network, protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args)
                {
                    MinProtocolVersion = ProtocolVersion.ALT_PROTOCOL_VERSION
                };

                var dnsSettings = new DnsSettings(nodeSettings);

                var isDns = !IsNullOrWhiteSpace(dnsSettings.DnsHostName) &&
                            !IsNullOrWhiteSpace(dnsSettings.DnsNameServer) &&
                            !IsNullOrWhiteSpace(dnsSettings.DnsMailBox);

                var builder = new FullNodeBuilder()
                              .UseNodeSettings(nodeSettings);

                if (isDns)
                {
                    if (args.Contains("-cold"))
                    {
                        throw new InvalidOperationException("-cold not allowed with Dns");
                    }

                    // Run as a full node with DNS or just a DNS service?
                    if (dnsSettings.DnsFullNode)
                    {
                        builder = builder
                                  .UseBlockStore()
                                  .UseRedstonePosConsensus()
                                  .UseMempool()
                                  .UseWallet()
                                  .AddRedstoneMining();
                    }
                    else
                    {
                        builder = builder.UsePosConsensus();
                    }

                    builder = builder
                              .UseApi()
                              .AddRPC()
                              .UseDns();
                }
                else
                {
                    builder = builder
                              .UseBlockStore()
                              .UseRedstonePosConsensus()
                              .UseMempool()
                              .UseWallet()
                              .UseColdStakingWallet()
                              .AddRedstoneMining()
                              .UseApi()
                              .UseApps()
                              .AddRPC();
                }

                var node = builder.Build();

                if (node != null)
                {
                    await node.RunAsync();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.ToString());
            }
        }