public override byte[] BitcoinSerialize()
{
using (var buf = new MemoryStream())
{
// Version, for some reason.
Utils.Uint32ToByteStreamLe(NetworkParameters.ProtocolVersion, buf);
// Then a vector of block hashes. This is actually a "block locator", a set of block
// identifiers that spans the entire chain with exponentially increasing gaps between
// them, until we end up at the genesis block. See CBlockLocator::Set()
buf.Write(new VarInt((ulong) _locator.Count).Encode());
foreach (var hash in _locator)
{
// Have to reverse as wire format is little endian.
buf.Write(Utils.ReverseBytes(hash.Bytes));
}
// Next, a block ID to stop at.
buf.Write(_stopHash.Bytes);
return buf.ToArray();
}
}