public void TestRoundtrip() { var set = new List <UInt32>() { 471105047 }; set.ForEach(compact => { var expected = Mint.BigToCompact(Mint.DiffToTarget(Mint.CompactToDiff(compact))); bool isValid = compact == expected; Assert.IsTrue(isValid); }); }
public void ShouldCovertToTarget() { var set = new[] { new object[] { 21.345F, "1263037534708007065233903449077122707924414303996398674892185141248" }, new object[] { 6.15F, "4383664314154799371057726451385090274339071401122701325781576974336" }, new object[] { 56.08F, "480733493559447088382085585624766859301132742736115421675251564544" }, new object[] { 18.5007F, "1457217015401058230710519728509336428455980242272185129797989433344" }, new object[] { 7F, "3851362069648898194808762653391849309347085353924666742105907920896" } }; foreach (var i in set) { float data = (float)i[0]; string encoded = (string)i[1]; var bn = Mint.DiffToTarget(data); bool isValid = bn.ToString() == encoded; Assert.IsTrue(isValid); } }
public uint SetBitsWithDifficulty(float diff) { this.Bits = Mint.BigToCompact(Mint.DiffToTarget(diff)); return(this.Bits.Value); }