Skip to content

Commit

Permalink
Use the DNS seeds in Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Coding-Enthusiast committed May 7, 2024
1 parent 3abbd0a commit e2c0fd1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
25 changes: 2 additions & 23 deletions Src/Denovo/Models/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,12 @@ public PeerDiscoveryOption SelectedPeerDiscoveryOption
}


public static readonly string[] DnsMain = new string[]
{
"seed.bitcoin.sipa.be", // Pieter Wuille, only supports x1, x5, x9, and xd
"dnsseed.bluematt.me", // Matt Corallo, only supports x9
"dnsseed.bitcoin.dashjr.org", // Luke Dashjr
"seed.bitcoinstats.com", // Christian Decker, supports x1 - xf
"seed.bitcoin.jonasschnelli.ch", // Jonas Schnelli, only supports x1, x5, x9, and xd
"seed.btc.petertodd.org", // Peter Todd, only supports x1, x5, x9, and xd
"seed.bitcoin.sprovoost.nl", // Sjors Provoost
"dnsseed.emzy.de", // Stephan Oeste
"seed.bitcoin.wiz.biz", // Jason Maurice
};

public static readonly string[] DnsTest = new string[]
{
"testnet-seed.bitcoin.jonasschnelli.ch",
"seed.tbtc.petertodd.org",
"seed.testnet.bitcoin.sprovoost.nl",
"testnet-seed.bluematt.me",
};

private string GetDnsList()
{
return Network switch
{
NetworkType.MainNet => string.Join(Environment.NewLine, DnsMain),
NetworkType.TestNet => string.Join(Environment.NewLine, DnsTest),
NetworkType.MainNet => string.Join(Environment.NewLine, Constants.GetMainNetDnsSeeds()),
NetworkType.TestNet => string.Join(Environment.NewLine, Constants.GetTestNetDnsSeeds()),
NetworkType.RegTest => "Not defined.",
_ => "Not defined."
};
Expand Down
11 changes: 6 additions & 5 deletions Src/Denovo/ViewModels/ConfigurationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Avalonia.Controls.ApplicationLifetimes;
using Denovo.Models;
using Denovo.MVVM;
using Denovo.Services;
using System.Collections.Generic;
using System.ComponentModel;

Expand All @@ -18,15 +17,17 @@ namespace Denovo.ViewModels
public class ConfigurationViewModel : VmWithSizeBase
{
// This will make designer happy
public ConfigurationViewModel() : base(500, 600)
public ConfigurationViewModel() : this(new Configuration(NetworkType.MainNet))
{
Config = new Configuration(NetworkType.MainNet);
}

public ConfigurationViewModel(Configuration config) : base(500, 600)
{
Config = config;
Config.PropertyChanged += Config_PropertyChanged;

ClientTypes = EnumHelper.GetAllEnumValues<ClientType>();
PeerDiscoveryOptions = EnumHelper.GetAllEnumValues<PeerDiscoveryOption>();
}


Expand All @@ -50,8 +51,8 @@ private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e)
}

public Configuration Config { get; set; }
public IEnumerable<ClientType> ClientTypes { get; } = EnumHelper.GetAllEnumValues<ClientType>();
public IEnumerable<PeerDiscoveryOption> PeerDiscoveryOptions { get; } = EnumHelper.GetAllEnumValues<PeerDiscoveryOption>();
public IEnumerable<ClientType> ClientTypes { get; }
public IEnumerable<PeerDiscoveryOption> PeerDiscoveryOptions { get; }

private string _desc;
public string Desc
Expand Down
4 changes: 2 additions & 2 deletions Src/Denovo/ViewModels/MinerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public MinerViewModel() : base(650, 650)
AllNodes = new NodePool(5);
MinimalClientSettings clientSettings = new(NetworkType.TestNet, 5, AllNodes)
{
DnsSeeds = Configuration.DnsTest,
DnsSeeds = Constants.GetTestNetDnsSeeds(),
UserAgent = "/Satoshi:0.22.0/",
};
client = new MinimalClient(clientSettings);
Expand Down Expand Up @@ -114,7 +114,7 @@ public async void StartMining()

IBlock result = await miner.Start(prvBlock, BlockHeight, tokenSource.Token);

if (!(result is null))
if (result is not null)
{
FastStream stream = new();
result.Serialize(stream);
Expand Down
2 changes: 1 addition & 1 deletion Src/Denovo/ViewModels/PushTxViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Connect()
{
settings = new(SelectedNetwork, 4, null)
{
DnsSeeds = SelectedNetwork == NetworkType.MainNet ? Configuration.DnsMain : Configuration.DnsTest,
DnsSeeds = SelectedNetwork == NetworkType.MainNet ? Constants.GetMainNetDnsSeeds() : Constants.GetTestNetDnsSeeds(),
UserAgent = "/Satoshi:0.22.0/",
};
client = new(settings);
Expand Down
2 changes: 2 additions & 0 deletions Src/Denovo/Views/ConfigurationView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</Grid>
</TabItem>-->


<TabItem Header="Paths">
<Grid ColumnDefinitions="auto,*,auto" RowDefinitions="auto,auto">
<TextBlock Text="Blockchain path:"
Expand All @@ -57,6 +58,7 @@
</Grid>
</TabItem>


<TabItem Header="Connection">
<StackPanel Margin="5" Spacing="3">
<CheckBox Content="Accept incoming connections"
Expand Down

0 comments on commit e2c0fd1

Please sign in to comment.