}
/// <summary>
- /// Get current instance as sequence of bytes
+ /// Get instance as sequence of bytes
/// </summary>
/// <returns>Byte sequence</returns>
- public IList<byte> Bytes
+ public static implicit operator byte[] (CBlock b)
{
- get
- {
- var r = new List<byte>();
+ var r = new List<byte>();
- r.AddRange(header.Bytes);
- r.AddRange(VarInt.EncodeVarInt(vtx.LongLength)); // transactions count
+ r.AddRange((byte[])b.header);
+ r.AddRange(VarInt.EncodeVarInt(b.vtx.LongLength)); // transactions count
- foreach (var tx in vtx)
- {
- r.AddRange(tx.Bytes);
- }
+ foreach (var tx in b.vtx)
+ {
+ r.AddRange((byte[])tx);
+ }
- r.AddRange(VarInt.EncodeVarInt(signature.LongLength));
- r.AddRange(signature);
+ r.AddRange(VarInt.EncodeVarInt(b.signature.LongLength));
+ r.AddRange(b.signature);
- return r;
- }
+ return r.ToArray();
}
/// <summary>
foreach (var tx in vtx)
{
- merkleTree.AddRange(Hash256.ComputeRaw256(tx.Bytes));
+ merkleTree.AddRange(Hash256.ComputeRaw256(tx));
}
int levelOffset = 0;