Skip to content

Commit

Permalink
Add nodes (stratisproject#23)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bokobza authored and monsieurleberre committed Jun 13, 2018
1 parent 4cb9cd5 commit 0c41a24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<string>("publickey", null);
this.FederationFolder = configReader.GetOrDefault<string>("federationfolder", null);
this.MemberPrivateFolder = configReader.GetOrDefault<string>("memberprivatefolder", null);
this.CounterChainApiPort = configReader.GetOrDefault("counterchainapiport", 0);

this.FederationNodeIPs = configReader.GetOrDefault<string>("federationips", null)?
.Split(',').Select(IPAddress.Parse)
.Where(ip => ip.ToString() != connectionManagerSettings.ExternalEndpoint.Address.ToString());

this.FederationNodeIps = configReader.GetOrDefault<string>("federationips", null)?.Split(',').Select(a => a.ToIPEndPoint(nodeSettings.Network.DefaultPort));
}

public IEnumerable<IPAddress> FederationNodeIPs { get; set; }
public IEnumerable<IPEndPoint> FederationNodeIps { get; set; }

/// <summary>
/// The MemberName is used to distiguish between federation gateways in the debug logs.
Expand Down

0 comments on commit 0c41a24

Please sign in to comment.