-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathNodeBuilder.cs
More file actions
96 lines (86 loc) · 3.38 KB
/
NodeBuilder.cs
File metadata and controls
96 lines (86 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using Blockcore.Builder;
using Blockcore.Configuration;
using Blockcore.Features.BlockStore;
using Blockcore.Features.ColdStaking;
using Blockcore.Features.Consensus;
using Blockcore.Features.Consensus.Interfaces;
using Blockcore.Features.Diagnostic;
using Blockcore.Features.MemoryPool;
using Blockcore.Features.Miner;
using Blockcore.Features.RPC;
using Blockcore.Features.Wallet;
using Blockcore.Features.NodeHost;
using Blockcore.Features.Dns;
using Blockcore.Features.Miner.Interfaces;
using Blockcore.Persistence;
using Blockcore.Features.Notifications;
using Blockcore.Features.WalletWatchOnly;
using Blockcore.Networks.X1.Components;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Blockcore.Node
{
public static class NodeBuilder
{
public static PersistenceProviderManager persistenceProviderManager;
public static IFullNodeBuilder Create(string chain, NodeSettings settings)
{
chain = chain.ToUpperInvariant();
IFullNodeBuilder nodeBuilder = CreateBaseBuilder(chain, settings);
switch (chain)
{
case "BTC":
case "XRC":
nodeBuilder.UsePowConsensus().AddMining().UseWallet();
break;
case "X1":
nodeBuilder.UseX1Consensus().UseColdStakingWallet();
break;
case "AMS":
case "X42":
case "BCP":
case "CITY":
case "STRAT":
case "STRAX":
case "RUTA":
case "EXOS":
case "XDS":
case "XLR":
case "IMPLX":
case "MOL":
case "HOME":
case "SERF":
case "CYBITS":
case "SBC":
case "RSC":
nodeBuilder.UsePosConsensus().AddPowPosMining().UseColdStakingWallet();
break;
}
return nodeBuilder;
}
private static IFullNodeBuilder CreateBaseBuilder(string chain, NodeSettings settings)
{
IFullNodeBuilder nodeBuilder = new FullNodeBuilder()
.UseNodeSettings(settings)
.UseBlockStore()
.UseMempool()
//.UseBlockNotification() this feature is broken and anyway its not used
// .UseTransactionNotification() this feature is broken and anyway its not used
.UseNodeHost()
.AddRPC()
.UseDiagnosticFeature();
UseDnsFullNode(nodeBuilder, settings);
return nodeBuilder;
}
static void UseDnsFullNode(IFullNodeBuilder nodeBuilder, NodeSettings nodeSettings)
{
if (nodeSettings.ConfigReader.GetOrDefault("dnsfullnode", false, nodeSettings.Logger))
{
var dnsSettings = new DnsSettings(nodeSettings);
if (string.IsNullOrWhiteSpace(dnsSettings.DnsHostName) || string.IsNullOrWhiteSpace(dnsSettings.DnsNameServer) || string.IsNullOrWhiteSpace(dnsSettings.DnsMailBox))
throw new ConfigurationException("When running as a DNS Seed service, the -dnshostname, -dnsnameserver and -dnsmailbox arguments must be specified on the command line.");
nodeBuilder.UseDns();
}
}
}
}