Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Blockcore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "x42.Networks", "Networks\x4
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "x42.Node", "Networks\x42\x42.Node\x42.Node.csproj", "{8E17F166-F15A-42F7-9407-06CE2A4AA0AF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Node", "Node", "{8820C3A5-74B4-45AB-B80C-2495DFBA4A2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blockcore.Node", "Node\Blockcore.Node\Blockcore.Node.csproj", "{D0A183FE-C913-4F8F-92EC-BD4502745140}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -295,6 +299,10 @@ Global
{8E17F166-F15A-42F7-9407-06CE2A4AA0AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E17F166-F15A-42F7-9407-06CE2A4AA0AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E17F166-F15A-42F7-9407-06CE2A4AA0AF}.Release|Any CPU.Build.0 = Release|Any CPU
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -347,6 +355,7 @@ Global
{88A9A633-DA22-412B-A04C-2A3405D3E2C8} = {3B56C02B-4468-4268-B797-851562789FCC}
{36CE71D7-812A-40D7-96B7-8220E8E86643} = {88A9A633-DA22-412B-A04C-2A3405D3E2C8}
{8E17F166-F15A-42F7-9407-06CE2A4AA0AF} = {88A9A633-DA22-412B-A04C-2A3405D3E2C8}
{D0A183FE-C913-4F8F-92EC-BD4502745140} = {8820C3A5-74B4-45AB-B80C-2495DFBA4A2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C780ABA-5872-4B83-AD3F-A5BD423AD907}
Expand Down
29 changes: 29 additions & 0 deletions src/Node/Blockcore.Node/Blockcore.Node.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Authors>Blockcore</Authors>
<AssemblyTitle>Blockcore.Node</AssemblyTitle>
<AssemblyName>Blockcore.Node</AssemblyName>
<PackageId>Blockcore.Node</PackageId>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Networks\Bitcoin\Blockcore.Networks.Bitcoin\Blockcore.Networks.Bitcoin.csproj" />
<ProjectReference Include="..\..\Networks\City\City\City.csproj" />
<ProjectReference Include="..\..\Networks\Stratis\Blockcore.Networks.Stratis\Blockcore.Networks.Stratis.csproj" />
<ProjectReference Include="..\..\Networks\x42\x42\x42.Networks.csproj" />
<ProjectReference Include="..\..\Networks\Xds\Blockcore.Networks.Xds\Blockcore.Networks.Xds.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.Api\Blockcore.Features.Api.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.BlockStore\Blockcore.Features.BlockStore.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.ColdStaking\Blockcore.Features.ColdStaking.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.Diagnostic\Blockcore.Features.Diagnostic.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.Miner\Blockcore.Features.Miner.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.RPC\Blockcore.Features.RPC.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.SignalR\Blockcore.Features.SignalR.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.Wallet\Blockcore.Features.Wallet.csproj" />
</ItemGroup>

</Project>
49 changes: 49 additions & 0 deletions src/Node/Blockcore.Node/NetworkSelector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Blockcore.Configuration;
using NBitcoin.Protocol;

namespace Blockcore.Node
{
public static class NetworkSelector
{
public static NodeSettings Create(string chain, string[] args)
{
chain = chain.ToUpperInvariant();

NodeSettings nodeSettings = null;

switch (chain)
{
case "BTC":
nodeSettings = new NodeSettings(networksSelector: Blockcore.Networks.Bitcoin.Networks.Bitcoin, args: args);
break;
case "CITY":
nodeSettings = new NodeSettings(networksSelector: City.Networks.Networks.City,
protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args)
{
MinProtocolVersion = ProtocolVersion.ALT_PROTOCOL_VERSION
};
break;
case "STRAT":
nodeSettings = new NodeSettings(networksSelector: Blockcore.Networks.Stratis.Networks.Stratis,
protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args);
break;
case "X42":
nodeSettings = new NodeSettings(networksSelector: x42.Networks.Networks.x42,
protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args)
{
MinProtocolVersion = ProtocolVersion.ALT_PROTOCOL_VERSION
};
break;
case "XDS":
nodeSettings = new NodeSettings(networksSelector: Blockcore.Networks.Xds.Networks.Xds,
protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args)
{
MinProtocolVersion = ProtocolVersion.ALT_PROTOCOL_VERSION
};
break;
}

return nodeSettings;
}
}
}
52 changes: 52 additions & 0 deletions src/Node/Blockcore.Node/NodeBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Blockcore.Builder;
using Blockcore.Configuration;
using Blockcore.Features.Api;
using Blockcore.Features.BlockStore;
using Blockcore.Features.ColdStaking;
using Blockcore.Features.Consensus;
using Blockcore.Features.Diagnostic;
using Blockcore.Features.MemoryPool;
using Blockcore.Features.Miner;
using Blockcore.Features.RPC;
using Blockcore.Features.Wallet;

namespace Blockcore.Node
{
public static class NodeBuilder
{
public static IFullNodeBuilder Create(string chain, NodeSettings settings)
{
chain = chain.ToUpperInvariant();

IFullNodeBuilder nodeBuilder = CreateBaseBuilder(chain, settings);

switch (chain)
{
case "BTC":
nodeBuilder.UsePowConsensus().AddMining().UseWallet();
break;
case "CITY":
case "STRAT":
case "X42":
case "XDS":
nodeBuilder.UsePosConsensus().AddPowPosMining().UseColdStakingWallet();
break;
}

return nodeBuilder;
}

private static IFullNodeBuilder CreateBaseBuilder(string chain, NodeSettings settings)
{
IFullNodeBuilder nodeBuilder = new FullNodeBuilder()
.UseNodeSettings(settings)
.UseBlockStore()
.UseMempool()
.UseApi()
.AddRPC()
.UseDiagnosticFeature();

return nodeBuilder;
}
}
}
58 changes: 58 additions & 0 deletions src/Node/Blockcore.Node/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Blockcore.Builder;
using Blockcore.Configuration;
using Blockcore.Features.SignalR;
using Blockcore.Features.SignalR.Broadcasters;
using Blockcore.Features.SignalR.Events;
using Blockcore.Utilities;

namespace Blockcore.Node
{
public class Program
{
public static async Task Main(string[] args)
{
try
{
string chain = args
.DefaultIfEmpty("--chain=BTC")
.Where(arg => arg.StartsWith("--chain", ignoreCase: true, CultureInfo.InvariantCulture))
.Select(arg => arg.Replace("--chain=", string.Empty, ignoreCase: true, CultureInfo.InvariantCulture))
.FirstOrDefault();

NodeSettings nodeSettings = NetworkSelector.Create(chain, args);
IFullNodeBuilder nodeBuilder = NodeBuilder.Create(chain, nodeSettings);

if (nodeSettings.EnableSignalR)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh this stuff should be hidden in the feature (well that's for another PR)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SignalR parts? Yes it should.

{
nodeBuilder.AddSignalR(options =>
{
options.EventsToHandle = new[]
{
(IClientEvent) new BlockConnectedClientEvent(),
new TransactionReceivedClientEvent()
};

options.ClientEventBroadcasters = new[]
{
(Broadcaster: typeof(StakingBroadcaster), ClientEventBroadcasterSettings: new ClientEventBroadcasterSettings { BroadcastFrequencySeconds = 5 }),
(Broadcaster: typeof(WalletInfoBroadcaster), ClientEventBroadcasterSettings: new ClientEventBroadcasterSettings { BroadcastFrequencySeconds = 5 })
};
});
}

IFullNode node = nodeBuilder.Build();

if (node != null)
await node.RunAsync();
}
catch (Exception ex)
{
Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex);
}
}
}
}
64 changes: 64 additions & 0 deletions src/Node/Blockcore.Node/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"profiles": {
"BTC (MAIN/RPC)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser"
},
"BTC (MAIN/RPC/LOW-MEM)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -maxblkmem=5 -dbcache=50"
},
"BTC (TEST/RPC)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -testnet"
},
"BTC (MAIN/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata"
},
"BTC (TEST/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -testnet"
},
"BTC (MAIN/LOCAL/RPC/DEFAULT)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -defaultwalletname=default -defaultwalletpassword=default -unlockdefaultwallet -server"
},
"BTC (TEST/LOCAL/RPC/DEFAULT)": {
"commandName": "Project",
"commandLineArgs": "-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -defaultwalletname=default -defaultwalletpassword=default -unlockdefaultwallet -server -testnet"
},
"CITY (MAIN/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=CITY -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata"
},
"CITY (TEST/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=CITY -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -testnet"
},
"STRAT (MAIN/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=STRAT -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata"
},
"STRAT (TEST/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=STRAT -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -testnet"
},
"X42 (MAIN/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=X42-server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata"
},
"X42 (TEST/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=X42 -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -testnet"
},
"XDS (MAIN/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=XDS -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata"
},
"XDS (TEST/LOCAL/RPC)": {
"commandName": "Project",
"commandLineArgs": "--chain=XDS -server -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -testnet"
}
}
}