Seq(IPersistentMap meta, ISeq s, int i, FullNode node) : base(meta) { _s = s; _i = i; _node = node; }
public static bool AreNodesSyncedTemp(CoreNode node1, FullNode node2) { if (node1.FullNode.Chain.Tip.HashBlock != node2.Chain.Tip.HashBlock) { return(false); } if (node1.FullNode.ChainBehaviorState.ConsensusTip.HashBlock != node2.ChainBehaviorState.ConsensusTip.HashBlock) { return(false); } if (node1.FullNode.GetBlockStoreTip().HashBlock != node2.GetBlockStoreTip().HashBlock) { return(false); } if (node1.FullNode.MempoolManager().InfoAll().Count != node2.MempoolManager().InfoAll().Count) { return(false); } if (node1.FullNode.WalletManager().WalletTipHash != node2.WalletManager().WalletTipHash) { return(false); } //if (node1.CreateRPCClient().GetBestBlockHash() != node2.CreateRPCClient().GetBestBlockHash()) return false; return(true); }
private INode CommitFullNode(FullNode fullNode, bool rehearsal) { var virtualChildren = new INode?[FullNode.ChildrenCount]; for (int i = 0; i < FullNode.ChildrenCount; ++i) { INode?child = fullNode.Children[i]; virtualChildren[i] = child is null ? null : Commit(child, rehearsal); } fullNode = new FullNode(virtualChildren.ToImmutableArray()); if (fullNode.Serialize().Length <= HashDigest <SHA256> .Size) { return(fullNode); } else { var fullNodeHash = fullNode.Hash(); if (!rehearsal) { KeyValueStore.Set( fullNodeHash.ToByteArray(), fullNode.Serialize()); } return(new HashNode(fullNodeHash)); } }
public static void Initialize(IEnumerable <ServiceDescriptor> services, FullNode fullNode) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseUrls(fullNode.Settings.ApiUri.ToString()) .ConfigureServices(collection => { if (services == null || fullNode == null) { return; } // copies all the services defined for the full node to the Api. // also copies over singleton instances already defined foreach (var service in services) { var obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType); if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null) { collection.AddSingleton(service.ServiceType, obj); } else { collection.Add(service); } } }) .UseStartup <Startup>() .Build(); host.Start(); }
public static IWebHost Initialize(IEnumerable <ServiceDescriptor> services, FullNode fullNode, ApiSettings apiSettings, ICertificateStore store, IWebHostBuilder webHostBuilder) { Guard.NotNull(fullNode, nameof(fullNode)); Guard.NotNull(webHostBuilder, nameof(webHostBuilder)); Uri apiUri = apiSettings.ApiUri; X509Certificate2 certificate = apiSettings.UseHttps ? GetHttpsCertificate(apiSettings.HttpsCertificateFilePath, store) : null; webHostBuilder .UseKestrel(options => { if (!apiSettings.UseHttps) { return; } Action <ListenOptions> configureListener = listenOptions => { listenOptions.UseHttps(certificate); }; var ipAddresses = Dns.GetHostAddresses(apiSettings.ApiUri.DnsSafeHost); foreach (var ipAddress in ipAddresses) { options.Listen(ipAddress, apiSettings.ApiPort, configureListener); } }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseUrls(apiUri.ToString()) .ConfigureServices(collection => { if (services == null) { return; } // copies all the services defined for the full node to the Api. // also copies over singleton instances already defined foreach (ServiceDescriptor service in services) { object obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType); if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null) { collection.AddSingleton(service.ServiceType, obj); } else { collection.Add(service); } } }) .UseStartup <Startup>(); IWebHost host = webHostBuilder.Build(); host.Start(); return(host); }
public ApiFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, ApiFeatureOptions apiFeatureOptions, IAsyncLoopFactory asyncLoopFactory) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.apiFeatureOptions = apiFeatureOptions; this.asyncLoopFactory = asyncLoopFactory; }
public bool AddToStratisMempool(Transaction trx) { FullNode fullNode = (this.runner as StratisBitcoinPowRunner).FullNode; var state = new MempoolValidationState(true); return(fullNode.MempoolManager().Validator.AcceptToMemoryPool(state, trx).Result); }
public RPCFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, NodeSettings nodeSettings, ILoggerFactory loggerFactory) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.nodeSettings = Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); }
public static async Task MainAsync(string[] args) { try { Network network = null; if (args.Contains("-testnet")) { network = Network.DeStreamTest; } else { network = Network.DeStreamMain; } DeStreamNodeSettings nodeSettings = new DeStreamNodeSettings(network, ProtocolVersion.ALT_PROTOCOL_VERSION, args: args, loadConfiguration: false); Console.WriteLine($"current network: {network.Name}"); // NOTES: running BTC and STRAT side by side is not possible yet as the flags for serialization are static FullNode node = (FullNode) new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseBlockStore() .UsePosConsensus() .UseMempool() .UseWallet() .AddPowPosMining() .UseApi() .AddRPC() .Build(); //(Wallet wallet, Block block, ChainedHeader chainedHeader) result = TestClassHelper.CreateFirstTransaction(nodeSettings, node.WalletManager(), node.NodeService<WalletSettings>(), // node.NodeService<IWalletFeePolicy>()); //var walletManager = node.WalletManager(); //walletManager.Wallets.Add(result.wallet); //HdAddress addr = result.wallet.AccountsRoot.ElementAt(0).Accounts.ElementAt(0).ExternalAddresses.ElementAt(0); //Key key = result.wallet.GetExtendedPrivateKeyForAddress("password", addr).PrivateKey; //TestClassHelper.CreateTestBlock(node, key); //walletManager.SaveWallets(); //var test = node.WalletManager().GetSpendableTransactionsInWallet("myWallet1").Sum(s => s.Transaction.Amount); Process currentProcess = Process.GetCurrentProcess(); Console.WriteLine("##############################: " + currentProcess.Id.ToString()); int qwe0 = 1; if (node != null) { await node.RunAsync(); } int qwe = 1; } catch (Exception ex) { Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.Message); } }
public void Kill() { if (FullNode != null) { FullNode.Dispose(); } }
public RPCFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, NodeSettings nodeSettings, ILoggerFactory loggerFactory, RpcSettings rpcSettings) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.nodeSettings = nodeSettings; this.logger = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode"); this.rpcSettings = rpcSettings; }
public RPCFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, NodeSettings nodeSettings, ILoggerFactory loggerFactory, RpcSettings rpcSettings) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.nodeSettings = nodeSettings; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.rpcSettings = rpcSettings; }
private FullNode Restart(FullNode fullNode) { fullNode.Dispose(); fullNode.ThrowIfUncatchedException(); fullNode = StratisBitcoinRunner.BuildFullNode(fullNode.Settings); fullNode.Start(); return(fullNode); }
private INode InsertShortNode( ShortNode shortNode, ImmutableArray <byte> prefix, ImmutableArray <byte> key, INode value) { int CommonPrefixLen(ImmutableArray <byte> a, ImmutableArray <byte> b) { var length = Math.Min(a.Length, b.Length); foreach (var i in Enumerable.Range(0, length)) { if (a[i] != b[i]) { return(i); } } return(length); } int commonPrefixLength = CommonPrefixLen(shortNode.Key, key); if (commonPrefixLength == shortNode.Key.Length) { var nn = Insert( shortNode.Value, prefix.AddRange(key.Take(commonPrefixLength)), key.Skip(commonPrefixLength).ToImmutableArray(), value); return(new ShortNode(shortNode.Key, nn)); } var branch = new FullNode(); branch = branch.SetChild( key[commonPrefixLength], Insert( null, prefix.AddRange(key.Take(commonPrefixLength + 1)), key.Skip(commonPrefixLength + 1).ToImmutableArray(), value)); branch = branch.SetChild( shortNode.Key[commonPrefixLength], Insert( null, prefix.AddRange(shortNode.Key.Take(commonPrefixLength + 1)), shortNode.Key.Skip(commonPrefixLength + 1).ToImmutableArray(), shortNode.Value !)); if (commonPrefixLength == 0) { return(branch); } // extension node return(new ShortNode(key.Take(commonPrefixLength).ToArray(), branch)); }
public static IWebHostBuilder ForFullNode(this IWebHostBuilder hostBuilder, FullNode fullNode) { hostBuilder.ConfigureServices(s => { s.AddSingleton(fullNode); s.AddSingleton(fullNode.Network); }); return(hostBuilder); }
/// <summary> /// Constructs the AzureIndexerLoop. /// </summary> /// <param name="fullNode">The full node that will be indexed.</param> /// <param name="loggerFactory">The logger factory.</param> public AzureIndexerLoop(FullNode fullNode, ILoggerFactory loggerFactory) { this.asyncLoopFactory = fullNode.AsyncLoopFactory; this.FullNode = fullNode; this.Chain = fullNode.Chain; this.nodeLifetime = fullNode.NodeLifetime; this.indexerSettings = fullNode.NodeService <AzureIndexerSettings>(); this.logger = loggerFactory.CreateLogger(GetType().FullName); }
public void Start(string dataDir) { var args = NodeSettings.FromArguments(new string[] { "-conf=bitcoin.conf", "-datadir=" + dataDir }); var node = BuildFullNode(args); FullNode = node; FullNode.Start(); }
public Mining(FullNode fullNode, ConsensusLoop consensusLoop, ConcurrentChain chain, Network network, IDateTimeProvider dateTimeProvider, BlockAssemblerFactory blockAssemblerFactory) { this.fullNode = fullNode; this.consensusLoop = consensusLoop; this.chain = chain; this.network = network; this.dateTimeProvider = dateTimeProvider; this.blockAssemblerFactory = blockAssemblerFactory; }
private void WaitReachBlock(FullNode fullNode, int height) { while (true) { if (fullNode?.ConsensusLoop?.Tip?.Height >= height) { break; } } }
public TicketboothApiFeature( FullNode fullNode, IFullNodeBuilder fullNodeBuilder, ILoggerFactory loggerFactory, IOptions <TicketboothApiOptions> ticketboothApiOptions) { _fullNode = fullNode; _fullNodeBuilder = fullNodeBuilder; _apiOptions = ticketboothApiOptions; _logger = loggerFactory.CreateLogger <TicketboothApiFeature>(); }
public IndexerTaskFactory( FullNode node, IBlockRepository blockRepository, AzureStorageClient storageClient, IndexerSettings settings) { _network = node.Network; _blockRepository = blockRepository; _storageClient = storageClient; _settings = settings; }
void Initialize(IEnumerable <ServiceDescriptor> services, FullNode fullNode, SecureApiSettings secureApiSettings, IWebHostBuilder webHostBuilder) { this.secureApiListening = $"{secureApiSettings.SecureApiHostBinding}:{secureApiSettings.SecureApiPort}"; webHostBuilder .UseKestrel(options => { }) .UseUrls(this.secureApiListening) .UseStartup <Startup>() .ConfigureServices(collection => { if (services == null) { return; } // copies all the services defined for the full node to the Api. // also copies over singleton instances already defined foreach (ServiceDescriptor service in services) { // open types can't be singletons if (service.ServiceType.IsGenericType || service.Lifetime == ServiceLifetime.Scoped) { collection.Add(service); continue; } try { object obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType); if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null) { collection.AddSingleton(service.ServiceType, obj); } else { collection.Add(service); } } catch (Exception e) { Debug.WriteLine(e); } } }); this.webHost = webHostBuilder.Build(); this.webHost.Start(); }
public ApiFeature( IFullNodeBuilder fullNodeBuilder, FullNode fullNode, ApiFeatureOptions apiFeatureOptions, ApiSettings apiSettings, ILoggerFactory loggerFactory) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.apiFeatureOptions = apiFeatureOptions; this.apiSettings = apiSettings; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); }
public SecureApiHostFeature( IFullNodeBuilder fullNodeBuilder, FullNode fullNode, SecureApiSettings secureApiSettings, ILoggerFactory loggerFactory) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.secureApiSettings = secureApiSettings; this.logger = loggerFactory.CreateLogger(GetType().FullName); this.InitializeBeforeBase = true; }
public ApiFeature( IFullNodeBuilder fullNodeBuilder, FullNode fullNode, ApiFeatureOptions apiFeatureOptions, IAsyncLoopFactory asyncLoopFactory, ILoggerFactory loggerFactory) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.apiFeatureOptions = apiFeatureOptions; this.asyncLoopFactory = asyncLoopFactory; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); }
public static IWebHostBuilder ForFullNode(this IWebHostBuilder hostBuilder, FullNode fullNode) { hostBuilder.ConfigureServices(s => { s.AddMvcCore(o => { o.ModelBinderProviders.Insert(0, new DestinationModelBinder()); o.ModelBinderProviders.Insert(0, new MoneyModelBinder()); }); }); return(hostBuilder); }
public static IWebHost Initialize(IEnumerable <ServiceDescriptor> services, FullNode fullNode, SignalRSettings settings, IWebHostBuilder webHostBuilder) { Guard.NotNull(fullNode, nameof(fullNode)); Guard.NotNull(webHostBuilder, nameof(webHostBuilder)); Uri uri = settings.SignalRUri; webHostBuilder .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseUrls(uri.ToString()) .ConfigureServices(collection => { if (services == null) { return; } // copies all the services defined for the full node to the Api. // also copies over singleton instances already defined foreach (ServiceDescriptor service in services) { // open types can't be singletons if (service.ServiceType.IsGenericType || service.Lifetime == ServiceLifetime.Scoped) { collection.Add(service); continue; } object obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType); if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null) { collection.AddSingleton(service.ServiceType, obj); } else { collection.Add(service); } } }) .UseStartup <Startup>(); IWebHost host = webHostBuilder.Build(); host.Start(); return(host); }
public SimpleWalletFeature(ILoggerFactory loggerFactory, IFullNodeBuilder fullNodeBuilder, Stratis.Bitcoin.Signals.Signals signals, FullNode fullNode, SimpleWalletSettings walletSettings, SimpleWalletService walletService) { this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.signals = signals; this.walletService = walletService; this.fullNode = fullNode; this.fullNodeBuilder = fullNodeBuilder; this.walletSettings = walletSettings; }
public WebSocketFeature(IFullNodeBuilder fullNodeBuilder, FullNode fullNode, IWebSocketService service, WebSocketSettings settings, ILoggerFactory loggerFactory) { this.fullNodeBuilder = fullNodeBuilder; this.fullNode = fullNode; this.service = service; this.settings = settings; this.loggerFactory = loggerFactory; this.loggerFactory.AddProvider(new WebSocketLoggingProvider(service, new WebSocketLoggerConfiguration())); }
static void Main(string[] args) { string[] args2 = { "-testnet", "-ctb", //"ctb://7obtcd7mkosmxeuh.onion?h=03c632023c4a8587845ad918b8e5f53f7bf18319", "ctb://wljlc26vwmc65lk6.onion?h=0f802acf528ca7a0742c3074ba7daa35bdae98c9", "-origin", "xxxx", "-destination", "yyyy" }; FuncLoggerFactory loggerFactory = new FuncLoggerFactory(i => new CustomerConsoleLogger(i, (a, b) => true, false)); Logs.Configure(loggerFactory); ArgsReader argsReader = new ArgsReader(args2); if (!argsReader.VerifyArgs()) { return; } //we don't want to be anywhere near MainNet if (NodeSettings.PrintHelp(args, Network.Main)) { return; } Uri tumblerUri = new Uri(argsReader.UriString); //Start the engines! NodeSettings nodeSettings = NodeSettings.FromArguments(args2); FullNode fullNode = StartupFullNode(nodeSettings, tumblerUri); fullNode.Run(); // Not needed at all, invoke tumbler connection via the API //ITumbleBitManager tumbleBitManager = new TumbleBitManager(loggerFactory, fullNode.WalletManager, null, fullNode.Chain, Network.TestNet, fullNode.Signals); //use the tumblebitManager with a wait //tumbleBitManager.ConnectToTumblerAsync(tumblerUri).GetAwaiter().GetResult(); //we don't want to do this as it will lock up the console... //tumbleBitManager.TumbleAsync(argsReader.OriginWalletName, argsReader.DestinationWalletName).GetAwaiter().GetResult(); }
Seq(ISeq s, int i, FullNode node) { _s = s; _i = i; _node = node; }
Seq(IPersistentMap meta, ISeq s, int i, FullNode node) : base(meta) { _s = s; _i = i; _node = node; }
public static ISeq create(FullNode node, int i) { return i >= node._nodes.Length ? null : new Seq(node._nodes[i].nodeSeq(), i, node); }