Commit 6cde68e8 authored by Sergei Zubov's avatar Sergei Zubov

Fix API ports

parent 0370b7af
...@@ -25,6 +25,12 @@ namespace Stratis.Bitcoin.Features.Api ...@@ -25,6 +25,12 @@ namespace Stratis.Bitcoin.Features.Api
/// <summary>The default port used by the API when the node runs on the Stratis testnet network.</summary> /// <summary>The default port used by the API when the node runs on the Stratis testnet network.</summary>
public const int TestStratisApiPort = 38221; public const int TestStratisApiPort = 38221;
/// <summary>The default port used by the API when the node runs on the DeStream network.</summary>
public const int DefaultDeStreamApiPort = 56864;
/// <summary>The default port used by the API when the node runs on the DeStream test network.</summary>
public const int TestDeStreamApiPort = 56865;
/// <summary>The default port used by the API when the node runs on the Stratis network.</summary> /// <summary>The default port used by the API when the node runs on the Stratis network.</summary>
public const string DefaultApiHost = "http://localhost"; public const string DefaultApiHost = "http://localhost";
...@@ -113,11 +119,23 @@ namespace Stratis.Bitcoin.Features.Api ...@@ -113,11 +119,23 @@ namespace Stratis.Bitcoin.Features.Api
private static int GetDefaultPort(Network network) private static int GetDefaultPort(Network network)
{ {
if (network.IsBitcoin()) if (network.IsBitcoin())
{
return network.IsTest() ? TestBitcoinApiPort : DefaultBitcoinApiPort; return network.IsTest() ? TestBitcoinApiPort : DefaultBitcoinApiPort;
}
if (network.IsStratis())
{
return network.IsTest() ? TestStratisApiPort : DefaultStratisApiPort; return network.IsTest() ? TestStratisApiPort : DefaultStratisApiPort;
} }
if (network.IsDeStream())
{
return network.IsTest() ? TestDeStreamApiPort : DefaultDeStreamApiPort;
}
throw new ConfigurationException($"Invalid network {network.Name}.");
}
/// <summary>Prints the help information on how to configure the API settings to the logger.</summary> /// <summary>Prints the help information on how to configure the API settings to the logger.</summary>
/// <param name="network">The network to use.</param> /// <param name="network">The network to use.</param>
public static void PrintHelp(Network network) public static void PrintHelp(Network network)
......
using NBitcoin;
namespace Stratis.Bitcoin.Utilities
{
public static partial class NetworkExtensions
{
public static bool IsStratis(this Network network)
{
return network.Name.ToLowerInvariant().Contains("stratis");
}
public static bool IsDeStream(this Network network)
{
return network.Name.ToLowerInvariant().Contains("destream");
}
}
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ namespace Stratis.Bitcoin.Utilities ...@@ -5,7 +5,7 @@ namespace Stratis.Bitcoin.Utilities
/// <summary> /// <summary>
/// Extension methods for NBitcoin's Network class. /// Extension methods for NBitcoin's Network class.
/// </summary> /// </summary>
public static class NetworkExtensions public static partial class NetworkExtensions
{ {
/// <summary>Fake height value used in Coins to signify they are only in the memory pool (since 0.8).</summary> /// <summary>Fake height value used in Coins to signify they are only in the memory pool (since 0.8).</summary>
public const int MempoolHeight = 0x7FFFFFFF; public const int MempoolHeight = 0x7FFFFFFF;
...@@ -37,7 +37,8 @@ namespace Stratis.Bitcoin.Utilities ...@@ -37,7 +37,8 @@ namespace Stratis.Bitcoin.Utilities
/// <returns><c>true</c> if the specified network is bitcoin, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the specified network is bitcoin, <c>false</c> otherwise.</returns>
public static bool IsBitcoin(this Network network) public static bool IsBitcoin(this Network network)
{ {
return !network.Name.ToLowerInvariant().Contains("stratis"); return !network.Name.ToLowerInvariant().Contains("stratis") &&
!network.Name.ToLowerInvariant().Contains("destream");
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment