From 0c41a24d2965452dc527bac95df26ece98ec6149 Mon Sep 17 00:00:00 2001 From: Jeremy Bokobza Date: Wed, 13 Jun 2018 15:38:59 +0100 Subject: [PATCH] Add nodes (#23) * Remove special nuget location * added membername to config * added mainchain to launchSettings * Added addnode for federation ips * returned null if there are no fed ips --- .../FederationGatewayFeature.cs | 6 ++++++ .../FederationGatewaySettings.cs | 13 +++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewayFeature.cs b/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewayFeature.cs index f16362fa5bd..b18fced1fd3 100644 --- a/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewayFeature.cs +++ b/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewayFeature.cs @@ -83,6 +83,12 @@ public override void Initialize() this.crossChainTransactionMonitor.Initialize(federationGatewaySettings); this.monitorChainSessionManager.Initialize(); + // Connect the node to the other federation members. + foreach (var federationMemberIp in federationGatewaySettings.FederationNodeIps) + { + this.connectionManager.AddNodeAddress(federationMemberIp); + } + var networkPeerConnectionParameters = this.connectionManager.Parameters; networkPeerConnectionParameters.TemplateBehaviors.Add(new PartialTransactionsBehavior(this.loggerFactory, this.crossChainTransactionMonitor, this.generalPurposeWalletManager, this.counterChainSessionManager, this.network, this.federationGatewaySettings )); } diff --git a/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewaySettings.cs b/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewaySettings.cs index 217c0993321..3aec9f32b24 100644 --- a/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewaySettings.cs +++ b/src/Stratis.FederatedPeg.Features.FederationGateway/FederationGatewaySettings.cs @@ -6,6 +6,7 @@ using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Configuration.Settings; using Stratis.Bitcoin.Utilities; +using Stratis.Bitcoin.Utilities.Extensions; namespace Stratis.FederatedPeg.Features.FederationGateway { @@ -32,22 +33,18 @@ public FederationGatewaySettings(NodeSettings nodeSettings) this.MultiSigM = configReader.GetOrDefault("multisigM", payToMultisigScriptParams.SignatureCount); this.MultiSigN = configReader.GetOrDefault("multisigN", payToMultisigScriptParams.PubKeys.Length); - var connectionManagerSettings = new ConnectionManagerSettings(nodeSettings); - this.MemberName = - configReader.GetOrDefault("membername", connectionManagerSettings.ExternalEndpoint.ToString()); + this.MemberName = configReader.GetOrDefault("membername", "unspecified"); this.MultiSigWalletName = configReader.GetOrDefault("multisigwalletname", "multisig_wallet"); this.PublicKey = configReader.GetOrDefault("publickey", null); this.FederationFolder = configReader.GetOrDefault("federationfolder", null); this.MemberPrivateFolder = configReader.GetOrDefault("memberprivatefolder", null); this.CounterChainApiPort = configReader.GetOrDefault("counterchainapiport", 0); - - this.FederationNodeIPs = configReader.GetOrDefault("federationips", null)? - .Split(',').Select(IPAddress.Parse) - .Where(ip => ip.ToString() != connectionManagerSettings.ExternalEndpoint.Address.ToString()); + + this.FederationNodeIps = configReader.GetOrDefault("federationips", null)?.Split(',').Select(a => a.ToIPEndPoint(nodeSettings.Network.DefaultPort)); } - public IEnumerable FederationNodeIPs { get; set; } + public IEnumerable FederationNodeIps { get; set; } /// /// The MemberName is used to distiguish between federation gateways in the debug logs.