Exemple #1
0
        /// <summary>
        /// Configures the specified node type.
        /// </summary>
        /// <param name="name">Friendly name of the node (this isn't the agent prefix).</param>
        /// <param name="nodeType">Type of the node.</param>
        /// <param name="networkType">Type of the network.</param>
        /// <param name="daemonPath">Path to the node Daemon to run</param>
        /// <param name="defaultConfigurator">Optional function to setup a default NodeSetup configuration</param>
        /// <returns><see cref="NodeSetup"/> instance</returns>
        public static NodeSetup Configure(string name, NodeType nodeType, NetworkType networkType, string daemonPath, Func <NodeSetup, NodeSetup> defaultConfigurator = null)
        {
            NodeSetup nodeSetup = new NodeSetup(name, nodeType, networkType, daemonPath);

            defaultConfigurator?.Invoke(nodeSetup);
            return(nodeSetup);
        }
        private NodeSetup DefaultGatewayConfigurator(NodeSetup nodeSetup, int nodeIndex)
        {
            NodeType primaryNodeType = nodeSetup.NodeType;
            NodeType counterNodeType = primaryNodeType == NodeType.GatewayMain ? NodeType.GatewaySide : NodeType.GatewayMain;

            string chain = primaryNodeType == NodeType.GatewayMain ? "main" : "side";

            string portSuffix        = this.GetPortNumberSuffix(primaryNodeType, nodeIndex);
            string counterPortSuffix = this.GetPortNumberSuffix(counterNodeType, nodeIndex);

            nodeSetup
            .SetConsoleColor(GetConsoleColor(nodeIndex))
            .WithAgentPrefix($"fed{nodeIndex + 1}{chain}")
            .WithDataDir($"$root_datadir\\gateway{nodeIndex + 1}")
            .WithPort($"36{portSuffix}")
            .WithApiPort($"38{portSuffix}")
            .WithCounterChainApiPort($"38{counterPortSuffix}")
            .WithRedeemScript(this.scriptAndAddresses.payToMultiSig.ToString())
            .WithPublicKey(this.pubKeysByMnemonic[this.mnemonics[nodeIndex]].ToString());

            List <string> federationIps = chain == "main" ? this.mainFederationIps : this.sideFederationIps;

            //filter out current node from the federationIps
            nodeSetup.WithFederationIps(federationIps.Where(ip => !ip.Contains(nodeSetup.Port.ToString())));

            return(nodeSetup);
        }
        private void SetupNodes()
        {
            // Federation Gateways
            for (int i = 0; i < this.federationMembersCount; i++)
            {
                this.configuredGatewayNodes.Add(NodeSetup
                                                .Configure($"Gateway{i + 1} MAIN", NodeType.GatewayMain, NetworkType.Testnet, "$path_to_federationgatewayd", (nodeSetup) => this.DefaultGatewayConfigurator(nodeSetup, i))
                                                .WithCustomArguments("-mincoinmaturity=1 -mindepositconfirmations=1")
                                                );

                this.configuredGatewayNodes.Add(NodeSetup
                                                .Configure($"Gateway{i + 1} SIDE", NodeType.GatewaySide, NetworkType.Regtest, "$path_to_federationgatewayd", (nodeSetup) => this.DefaultGatewayConfigurator(nodeSetup, i))
                                                .WithCustomArguments("-mincoinmaturity=1 -mindepositconfirmations=1 -txindex = 1")
                                                );
            }

            // MainChainUser.
            this.configuredUserNodes.Add(NodeSetup
                                         .Configure($"MAIN Chain User", NodeType.UserMain, NetworkType.Testnet, "$path_to_stratisd")
                                         .SetConsoleColor("0D")
                                         .WithAgentPrefix("mainuser")
                                         .WithDataDir($"$root_datadir\\MainchainUser")
                                         .WithPort($"36178")
                                         .WithApiPort($"38221")
                                         .AddNodes(new string[] {
                "13.70.81.5",
                "52.151.76.252"
            })
                                         .WithCustomArguments("-whitelist=52.151.76.252")
                                         );

            // SidechainUser.
            this.configuredUserNodes.Add(NodeSetup
                                         .Configure($"SIDE Chain User", NodeType.UserSide, NetworkType.Regtest, "$path_to_sidechaind")
                                         .SetConsoleColor("0C")
                                         .WithAgentPrefix("sideuser")
                                         .WithDataDir($"$root_datadir\\SidechainUser")
                                         .WithPort($"26179")
                                         .WithApiPort($"38225")
                                         .AddNodes(this.configuredGatewayNodes
                                                   .Where(node => node.NodeType == NodeType.GatewaySide)
                                                   .Select(node => $"127.0.0.1:{node.Port.ToString()}")
                                                   )
                                         );
        }