public static War ByteArrayToWar(byte[] data) { War war = new War(); war.id = Op.Bytes2String(NuSD.DesegWithIdFromSeg(data, 0)); war.regEndBlock = Op.Bytes2BigInt(NuSD.DesegWithIdFromSeg(data, 1)); BigInteger height = Blockchain.GetHeight(); war.regLeftBlocks = war.regEndBlock - height; return(war); }
public void TestDataDesegWithID() { //public static byte[] tableThree = { 5, 1, 2, 3, 4, 5, 2, 12, 2, 1, 0 }; byte[] b1 = NuSD.DesegWithIdFromTable(tableThree, 0); byte[] b2 = NuSD.DesegWithIdFromTable(tableThree, 1); byte[] b3 = NuSD.DesegWithIdFromTable(tableThree, 2); byte[] seg = NuSD.Seg(tableThree); byte[] b4 = NuSD.DesegWithIdFromSeg(seg, 1); Assert.AreEqual(b1, new byte[] { 1, 2, 3, 4, 5 }); Assert.AreEqual(b2, new byte[] { 12, 2 }); Assert.AreEqual(b3, new byte[] { 0 }); Assert.AreEqual(b4, new byte[] { 12, 2 }); }