本文整理汇总了C#中Target.ToUInt256方法的典型用法代码示例。如果您正苦于以下问题:C# Target.ToUInt256方法的具体用法?C# Target.ToUInt256怎么用?C# Target.ToUInt256使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Target
的用法示例。
在下文中一共展示了Target.ToUInt256方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanReadConvertTargetToDifficulty
//https://en.bitcoin.it/wiki/Difficulty
public void CanReadConvertTargetToDifficulty()
{
var packed = new Target(TestUtils.ParseHex("1b0404cb"));
var unpacked = new Target(uint256.Parse("00000000000404CB000000000000000000000000000000000000000000000000"));
Assert.Equal(packed, unpacked);
Assert.Equal(packed, new Target(0x1b0404cb));
packed = new Target(TestUtils.ParseHex("1b8404cb"));
Assert.True(packed.ToBigInteger() < 0);
Assert.Equal(packed, new Target(0x1b8404cb));
packed = new Target(TestUtils.ParseHex("1d00ffff"));
Assert.Equal(1, packed.Difficulty);
Assert.Equal(Target.Difficulty1, packed);
packed = new Target(TestUtils.ParseHex("1b0404cb"));
Assert.Equal(16307.420938523983D, packed.Difficulty, "420938523983".Length);
Assert.Equal(packed, new Target((uint)0x1b0404cb));
Assert.Equal((uint)packed, (uint)0x1b0404cb);
packed = new Target(0x1d00ffff);
Assert.Equal((uint)packed, (uint)0x1d00ffff);
//Check http://blockchain.info/block-index/392672/0000000000000000511e193e22d2dfc02aea8037988f0c58e9834f4550e97702
packed = new Target(419470732);
Assert.Equal(6978842649.592383, packed.Difficulty, "592383".Length);
Assert.Equal((uint)packed, (uint)419470732);
Assert.True(uint256.Parse("0x0000000000000000511e193e22d2dfc02aea8037988f0c58e9834f4550e97702") < packed.ToUInt256());
//Check http://blockchain.info/block-index/394713/0000000000000000729a4a7e084c90f932d038c407a6535a51dfecdfba1c8906
Assert.True(uint256.Parse("0x0000000000000000729a4a7e084c90f932d038c407a6535a51dfecdfba1c8906 ") < new Target(419470732).ToUInt256());
var genesis = Network.Main.GetGenesis();
Assert.True(genesis.GetHash() < genesis.Header.Bits.ToUInt256());
}