-
Notifications
You must be signed in to change notification settings - Fork 89
Add Blockcore.Node project for quick and easy debug of multiple chains #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| { | ||
| 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); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.