public GetBlocksMessage Parse(byte[] payload)
        {
            var reader = new PayloadReader(payload);

            var version = reader.ReadUInt32();
            var count   = reader.ReadVarInt();

            throw new NotImplementedException();

            for (ulong i = 0; i < count; i++)
            {
            }

            reader.ThrowIfNotEndReached();
        }
Ejemplo n.º 2
0
        static readonly byte[] Services = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };  // TODO: Fill in services

        public static VersionMessage Parse(byte[] payload)
        {
            var reader = new PayloadReader(payload);

            var protocolVersion = reader.ReadUInt32();

            reader.Seek(8, SeekOrigin.Current);
            var timestamp = reader.ReadDateTimeOffset(true);

            reader.Seek(8, SeekOrigin.Current);
            var to = reader.ReadIPEndPoint();

            reader.Seek(8, SeekOrigin.Current);
            var from        = reader.ReadIPEndPoint();
            var nonce       = reader.ReadUInt64();
            var userAgent   = reader.ReadString();
            var startHeight = reader.ReadInt32();

            bool relay = true;

            if (reader.Position < payload.Length)
            {
                relay = reader.ReadBool();
            }

            if (reader.Position != payload.Length)
            {
                throw new Exception($"Unparsed data remaining in {nameof(VersionMessage)}");
            }

            return(new VersionMessage(
                       protocolVersion,
                       timestamp,
                       to,
                       from,
                       nonce,
                       userAgent,
                       startHeight,
                       relay
                       ));
        }