public NodeBuilder(string rootFolder) { this.Nodes = new List <CoreNode>(); this.ConfigParameters = new NodeConfigParameters(); this.rootFolder = rootFolder; }
public void Import(NodeConfigParameters configParameters) { foreach (KeyValuePair <string, string> kv in configParameters) { if (!this.ContainsKey(kv.Key)) { this.Add(kv.Key, kv.Value); } } }
public CoreNode CreateMainnetStratisXNode(string version = "2.0.0.5", bool useCookieAuth = false) { var parameters = new NodeConfigParameters(); parameters.Add("regtest", "0"); parameters.Add("server", "0"); string stratisDPath = GetStratisXPath(version); return(this.CreateNode(new StratisXRunner(this.GetNextDataFolderName(), stratisDPath), "stratis.conf", useCookieAuth, parameters)); }
public CoreNode CreateStratisCustomPowNode(Network network, NodeConfigParameters configParameters) { var callback = new Action <IFullNodeBuilder>(builder => builder .UseBlockStore() .UsePowConsensus() .UseMempool() .AddMining() .UseWallet() .AddRPC() .UseApi() .UseTestChainedHeaderTree() .MockIBD()); return(CreateCustomNode(callback, network, ProtocolVersion.PROTOCOL_VERSION, configParameters: configParameters)); }
/// <summary>A helper method to create a node instance with a non-standard set of features enabled. The node can be PoW or PoS, as long as the appropriate features are provided.</summary> /// <param name="callback">A callback accepting an instance of <see cref="IFullNodeBuilder"/> that constructs a node with a custom feature set.</param> /// <param name="network">The network the node will be running on.</param> /// <param name="protocolVersion">Use <see cref="ProtocolVersion.PROTOCOL_VERSION"/> for BTC PoW-like networks and <see cref="ProtocolVersion.ALT_PROTOCOL_VERSION"/> for Stratis PoS-like networks.</param> /// <param name="agent">A user agent string to distinguish different node versions from each other.</param> /// <param name="configParameters">Use this to pass in any custom configuration parameters used to set up the CoreNode</param> public CoreNode CreateCustomNode(Action <IFullNodeBuilder> callback, Network network, ProtocolVersion protocolVersion = ProtocolVersion.PROTOCOL_VERSION, string agent = "Custom", NodeConfigParameters configParameters = null, ProtocolVersion minProtocolVersion = ProtocolVersion.PROTOCOL_VERSION) { configParameters = configParameters ?? new NodeConfigParameters(); configParameters.SetDefaultValueIfUndefined("conf", "custom.conf"); string configFileName = configParameters["conf"]; configParameters.SetDefaultValueIfUndefined("datadir", this.GetNextDataFolderName(agent)); string dataDir = configParameters["datadir"]; configParameters.ToList().ForEach(p => this.ConfigParameters[p.Key] = p.Value); return(CreateNode(new CustomNodeRunner(dataDir, callback, network, protocolVersion, configParameters, agent, minProtocolVersion), configFileName)); }
/// <summary> /// Creates a Stratis Proof-of-Stake node. /// <para> /// <see cref="PeerDiscovery"/> and <see cref="PeerConnectorDiscovery"/> are disabled by default. /// </para> /// </summary> /// <param name="network">The network the node will run on.</param> /// <param name="agent">Overrides the node's agent prefix.</param> /// <param name="configParameters">Adds to the nodes configuration parameters.</param> /// <param name="isGateway">Whether the node is a Proven Headers gateway node.</param> /// <returns>The constructed PoS node.</returns> public CoreNode CreateStratisPosNode(Network network, string agent = "StratisBitcoin", NodeConfigParameters configParameters = null, bool isGateway = false) { return(CreateNode(new StratisBitcoinPosRunner(this.GetNextDataFolderName(), network, agent, isGateway), "stratis.conf", configParameters: configParameters)); }
/// <summary> /// Creates a Stratis Proof-of-Work node. /// <para> /// <see cref="PeerDiscovery"/> and <see cref="PeerConnectorDiscovery"/> are disabled by default. /// </para> /// </summary> /// <param name="network">The network the node will run on.</param> /// <param name="agent">Overrides the node's agent prefix.</param> /// <param name="configParameters">Adds to the nodes configuration parameters.</param> /// <returns>The constructed PoW node.</returns> public CoreNode CreateStratisPowNode(Network network, string agent = null, NodeConfigParameters configParameters = null) { return(CreateNode(new StratisBitcoinPowRunner(this.GetNextDataFolderName(), network, agent), configParameters: configParameters)); }
public CoreNode CreateStratisXNode(string version = "2.0.0.5", bool useCookieAuth = false, NodeConfigParameters configParameters = null) { string stratisDPath = GetStratisXPath(version); return(this.CreateNode(new StratisXRunner(this.GetNextDataFolderName(), stratisDPath), "stratis.conf", useCookieAuth, configParameters)); }
protected CoreNode CreateNode(NodeRunner runner, string configFile = "bitcoin.conf", bool useCookieAuth = false, NodeConfigParameters configParameters = null) { var node = new CoreNode(runner, configParameters, configFile, useCookieAuth); this.Nodes.Add(node); return(node); }
private void CreateConfigFile(NodeConfigParameters configParameters = null) { Directory.CreateDirectory(this.runner.DataFolder); configParameters = configParameters ?? new NodeConfigParameters(); configParameters.SetDefaultValueIfUndefined("regtest", "1"); configParameters.SetDefaultValueIfUndefined("rest", "1"); configParameters.SetDefaultValueIfUndefined("server", "1"); configParameters.SetDefaultValueIfUndefined("txindex", "1"); if (this.runner is BitcoinCoreRunner) { // TODO: Migrate to using `generatetoaddress` RPC for newer Core versions configParameters.SetDefaultValueIfUndefined("deprecatedrpc", "generate"); } if (!this.CookieAuth) { configParameters.SetDefaultValueIfUndefined("rpcuser", this.creds.UserName); configParameters.SetDefaultValueIfUndefined("rpcpassword", this.creds.Password); } // The debug log is disabled in stratisX when printtoconsole is enabled. // While further integration tests are being developed it makes sense // to always have the debug logs available, as there is minimal other // insight into the stratisd process while it is running. if (this.runner is StratisXRunner) { configParameters.SetDefaultValueIfUndefined("printtoconsole", "0"); configParameters.SetDefaultValueIfUndefined("debug", "1"); } else { configParameters.SetDefaultValueIfUndefined("printtoconsole", "1"); } configParameters.SetDefaultValueIfUndefined("keypool", "10"); configParameters.SetDefaultValueIfUndefined("agentprefix", "node" + this.ProtocolPort); configParameters.Import(this.ConfigParameters); // Need special handling for config files used by newer versions of Bitcoin Core. // These have specialised sections for [regtest], [test] and [main] in which certain options // only have an effect when they appear in their respective section. var builder = new StringBuilder(); // Scan for network setting. These need to be at the top of the config file. bool testnet = configParameters.Any(a => a.Key.Equals("testnet") && a.Value.Equals("1")); bool regtest = configParameters.Any(a => a.Key.Equals("regtest") && a.Value.Equals("1")); bool mainnet = !testnet && !regtest; if (testnet) { builder.AppendLine("testnet=1"); if (this.runner.UseNewConfigStyle) { builder.AppendLine("[test]"); } } if (regtest) { builder.AppendLine("regtest=1"); if (this.runner.UseNewConfigStyle) { builder.AppendLine("[regtest]"); } } if (mainnet) { // Mainnet is implied by the absence of both testnet and regtest. But it should still get its own config section. if (this.runner.UseNewConfigStyle) { builder.AppendLine("[main]"); } } foreach (KeyValuePair <string, string> kv in configParameters) { if (kv.Key.Equals("testnet") || kv.Key.Equals("regtest")) { continue; } builder.AppendLine(kv.Key + "=" + kv.Value); } File.WriteAllText(this.Config, builder.ToString()); }