public byte[] ToArray() { var ret = new byte[84 + HashCount.Size + FlagByteCount.Size + FlagByteCount + (32 * HashCount)]; var bh = BlockHeader.ToArray(); Buffer.BlockCopy(bh, 0, ret, 0, bh.Length); var tr = BitConverter.GetBytes(Transactions); Buffer.BlockCopy(tr, 0, ret, 80, tr.Length); var hc = HashCount.ToArray(); Buffer.BlockCopy(hc, 0, ret, 84, hc.Length); for (var x = 0; x < HashCount; x++) { var hx = Hashes[x].ToArray(); Buffer.BlockCopy(hx, 0, ret, 84 + hc.Length + (x * 32), hx.Length); } var fb = FlagByteCount.ToArray(); Buffer.BlockCopy(fb, 0, ret, 84 + hc.Length + (32 * HashCount), fb.Length); Buffer.BlockCopy(Flags, 0, ret, 84 + hc.Length + (32 * HashCount) + fb.Length, Flags.Length); return(ret); }
public byte[] ToArray() { var woffset = 0; var ret = new byte[Size]; ret.CopyAndIncr(BitConverter.GetBytes(Version), ref woffset); ret.CopyAndIncr(HashCount.ToArray(), ref woffset); foreach (var hash in Hashes) { ret.CopyAndIncr(hash.ToArray(), ref woffset); } ret.CopyAndIncr(StopHash.ToArray(), woffset); return(ret); }
public byte[] ToArray() { var woffset = 0; var ret = new byte[Size]; ret.CopyAndIncr(BlockHeader.ToArray(), ref woffset); ret.CopyAndIncr(BitConverter.GetBytes(Transactions), ref woffset); ret.CopyAndIncr(HashCount.ToArray(), ref woffset); foreach (var h in Hashes) { ret.CopyAndIncr(h.ToArray(), ref woffset); } ret.CopyAndIncr(FlagBytes.ToArray(), ref woffset); ret.CopyAndIncr(Flags, woffset); return(ret); }
public byte[] ToArray() { using (var ms = new MemoryStream()) { var v = BitConverter.GetBytes(Version); ms.Write(v, 0, v.Length); var hc = HashCount.ToArray(); ms.Write(hc, 0, hc.Length); for (var x = 0; x < HashCount; x++) { var xh = Hashes[x].HashBytes; ms.Write(xh, 0, xh.Length); } ms.Write(StopHash.HashBytes, 0, StopHash.HashBytes.Length); return(ms.ToArray()); } }