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
8 changes: 4 additions & 4 deletions NBitcoin.TestFramework/NodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private void CleanFolder()
}
catch (DirectoryNotFoundException) { }
}
#if !NOSOCKET

public void Sync(CoreNode node, bool keepConnection = false)
{
var rpc = CreateRPCClient();
Expand All @@ -401,7 +401,7 @@ public void Sync(CoreNode node, bool keepConnection = false)
if (!keepConnection)
rpc.DisconnectNode(node.Endpoint).GetAwaiter().GetResult();
}
#endif

private CoreNodeState _State;
public CoreNodeState State
{
Expand Down Expand Up @@ -466,16 +466,16 @@ public RestClient CreateRESTClient()
{
return new RestClient(new Uri("http://127.0.0.1:" + ports[1].ToString() + "/"));
}
#if !NOSOCKET

public Node CreateNodeClient()
{
return Node.Connect(Network, NodeEndpoint);
}

public Node CreateNodeClient(NodeConnectionParameters parameters)
{
return Node.Connect(Network, "127.0.0.1:" + ports[0].ToString(), parameters);
}
#endif

/// <summary>
/// Nodes connecting to this node will be whitelisted (default: false)
Expand Down
4 changes: 1 addition & 3 deletions NBitcoin.Tests/ProtocolTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !NOSOCKET

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If #if !NOSOCKET is removed from the first line, then it's safe to remove the last line containing #endif. This is because the whole file was not meant to be compiled for some TFMs.

using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -1195,4 +1194,3 @@ public void CanDownloadLastBlocks()
}
}
}
#endif
4 changes: 1 addition & 3 deletions NBitcoin.Tests/RPCClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,6 @@ public void CanTestMempoolAccept()
}
}

#if !NOSOCKET

[Fact]
[Trait("UnitTest", "UnitTest")]
public void onioncat_test()
Expand Down Expand Up @@ -1325,7 +1323,7 @@ public void RPCSendRPCException()
}
}
}
#endif

[Fact]
public void CanBackupWallet()
{
Expand Down
8 changes: 1 addition & 7 deletions NBitcoin.Tests/addrman_tests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#if !NOSOCKET
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;
using NBitcoin.Protocol;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace NBitcoin.Tests
Expand Down Expand Up @@ -175,4 +170,3 @@ private NetworkAddress RandomNetworkAddress(Random rand)
}
}
}
#endif
7 changes: 0 additions & 7 deletions NBitcoin/Bitcoin.Mainnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ private Network CreateMainnet()

builder.SetConsensus(consensus);

#if !NOSOCKET

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correctness of this file can be verified by looking that there are no more #if in this file.

builder.AddDNSSeeds(new[]
{
new DNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be"), // Pieter Wuille
Expand All @@ -91,7 +90,6 @@ private Network CreateMainnet()
});

builder.AddSeeds(LoadNetworkAddresses(GetMainnetSeeds(), builder));
#endif

var result = builder.BuildAndRegister();

Expand All @@ -108,9 +106,6 @@ private static void assert(bool v)
throw new InvalidOperationException("Invalid network");
}


#if !NOSOCKET

// https://github.com/bitcoin/bitcoin/blob/master/src/chainparamsseeds.h
// All these entries were prefixed with 0x00 because NBitcoin expects the service flags.
private byte[] GetMainnetSeeds() => new byte[]
Expand Down Expand Up @@ -1492,7 +1487,5 @@ private static void assert(bool v)
0x9f, 0xf4, 0x72, 0x7a, 0x9b, 0x20, 0x0c, 0x5c, 0x11, 0x3d, 0x22, 0xd6, 0x13, 0x88, 0x66, 0x74, 0xbf, 0x20,
0x8d
};

#endif
}
}
2 changes: 0 additions & 2 deletions NBitcoin/Bitcoin.MutinyNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ private Network CreateMutinyNet()
.SetName("mutinynet")
.AddAlias("bitcoin-mutinynet")
.AddAlias("btc-mutinynet")
#if !NOSOCKET
.AddSeeds(new[]
{
new Protocol.NetworkAddress(System.Net.IPAddress.Parse("45.79.52.207"), 38333)
})
#endif
.SetGenesis(
"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a008f4d5fae77031e8ad222030101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000");

Expand Down
2 changes: 0 additions & 2 deletions NBitcoin/Bitcoin.Signet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private Network CreateSignet(
});
}

#if !NOSOCKET
if (networkSeeds != null)
{
builder.AddSeeds(networkSeeds.Select(o => new Protocol.NetworkAddress(System.Net.IPAddress.Parse(o))));
Expand All @@ -93,7 +92,6 @@ private Network CreateSignet(
{
builder.AddSeeds(SignetSettings.DEFAULT_SIGNET_NETWORK_SEEDS.Select(o => new Protocol.NetworkAddress(System.Net.IPAddress.Parse(o))));
}
#endif

var network = builder.BuildAndRegister();

Expand Down
4 changes: 0 additions & 4 deletions NBitcoin/Bitcoin.Testnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ private Network CreateTestnet()
consensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 1456790400, 1493596800);
consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 1462060800, 1493596800);


builder.SetConsensus(consensus);


#if !NOSOCKET
builder.AddDNSSeeds(new[]
{
new DNSSeedData("bitcoin.jonasschnelli.ch", "testnet-seed.bitcoin.jonasschnelli.ch"),
Expand All @@ -107,7 +104,6 @@ private Network CreateTestnet()
};

builder.AddSeeds(LoadNetworkAddresses(pnSeed6_test, builder));
#endif

var result = builder.BuildAndRegister();

Expand Down
3 changes: 0 additions & 3 deletions NBitcoin/Bitcoin.Testnet4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ private Network CreateTestnet4()

builder.SetConsensus(consensus);


#if !NOSOCKET
builder.AddDNSSeeds(new[]
{
new DNSSeedData("bitcoin.sprovoost.nl", "seed.testnet4.bitcoin.sprovoost.nl"),
Expand All @@ -102,7 +100,6 @@ private Network CreateTestnet4()
};

builder.AddSeeds(LoadNetworkAddresses(pnSeed6_test, builder));
#endif

var result = builder.BuildAndRegister();

Expand Down
3 changes: 0 additions & 3 deletions NBitcoin/Bitcoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public Network GetNetwork(ChainName chainName)
return _Networks.TryGetValue(chainName, out var network) ? network : null;
}


#if !NOSOCKET
private static IEnumerable<NetworkAddress> LoadNetworkAddresses(byte[] payload, NetworkBuilder builder)
{
// Convert the pnSeeds array into usable address objects.
Expand Down Expand Up @@ -77,6 +75,5 @@ private static IEnumerable<NetworkAddress> LoadNetworkAddresses(byte[] payload,
}
}
}
#endif
}
}
6 changes: 0 additions & 6 deletions NBitcoin/BitcoinStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if !NOSOCKET
using System.Net.Sockets;
#endif
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
Expand Down Expand Up @@ -81,9 +79,7 @@ static BitcoinStream()
.First();
}

#if !NOSOCKET
private readonly bool _IsNetworkStream;
#endif
private readonly Stream _Inner;
public Stream Inner
{
Expand All @@ -104,9 +100,7 @@ public bool Serializing
public BitcoinStream(Stream inner, bool serializing)
{
_Serializing = serializing;
#if !NOSOCKET
_IsNetworkStream = inner is NetworkStream;
#endif
_Inner = inner;
}

Expand Down
2 changes: 0 additions & 2 deletions NBitcoin/ConsensusFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ public virtual Payload CreatePayload(string command)
"getdata" => new GetDataPayload(),
"headers" => new HeadersPayload(),
"block" => new BlockPayload(),
#if !NOSOCKET
"addr" => new AddrPayload(),
"addrv2" => new AddrV2Payload(),
"version" => new VersionPayload(),
#endif
"ping" => new PingPayload(),
"pong" => new PongPayload(),
"getaddr" => new GetAddrPayload(),
Expand Down
5 changes: 1 addition & 4 deletions NBitcoin/IpExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !NOSOCKET
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand All @@ -24,7 +23,6 @@ public static bool IsRFC1918(this IPAddress address)
(bytes[15 - 3] == 172 && (bytes[15 - 2] >= 16 && bytes[15 - 2] <= 31)));
}


public static bool IsIPv4(this IPAddress address)
{
return address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork || address.IsIPv4MappedToIPv6;
Expand Down Expand Up @@ -522,4 +520,3 @@ public static bool IsValid(this IPAddress address)
}
}
}
#endif
Loading
Loading