Exemple #1
0
        public VersionPayload(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires <ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires <ArgumentException>(buffer.Length >= VersionPayload.MinimumByteSize, "buffer");
            Contract.Requires <ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires <ArgumentOutOfRangeException>(offset <= buffer.Length - VersionPayload.MinimumByteSize, "offset");

            Version         = buffer.ReadUInt32(offset);
            Services        = (Services)buffer.ReadUInt64(offset + SERVICES_OFFSET);
            Timestamp       = buffer.ReadUInt64(offset + TIMESTAMP_OFFSET);
            EmittingAddress = new NetworkAddress(buffer, offset + EMIT_ADDRESS_OFFSET);
            if (Version >= 106)
            {
                ReceivingAddress = new NetworkAddress(buffer, offset + RECV_ADDRESS_OFFSET);
                Nonce            = buffer.ReadUInt64(offset + NONCE_OFFSET);
                SubVersionNum    = new VarString(buffer, offset + SUBVER_OFFSET);
            }
            else
            {
                ReceivingAddress = NetworkAddress.IPv6Any;
            }
            if (Version >= 209)
            {
                StartHeight = buffer.ReadUInt32(offset + STARTHEIGHT_OFFSET);
            }

            ByteSize = CalculateByteSize();
        }
        public VersionPayload(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires<ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires<ArgumentException>(buffer.Length >= VersionPayload.MinimumByteSize, "buffer");
            Contract.Requires<ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires<ArgumentOutOfRangeException>(offset <= buffer.Length - VersionPayload.MinimumByteSize, "offset");

            Version = buffer.ReadUInt32(offset);
            Services = (Services)buffer.ReadUInt64(offset + SERVICES_OFFSET);
            Timestamp = buffer.ReadUInt64(offset + TIMESTAMP_OFFSET);
            EmittingAddress = new NetworkAddress(buffer, offset + EMIT_ADDRESS_OFFSET);
            if (Version >= 106)
            {
                ReceivingAddress = new NetworkAddress(buffer, offset + RECV_ADDRESS_OFFSET);
                Nonce = buffer.ReadUInt64(offset + NONCE_OFFSET);
                SubVersionNum = new VarString(buffer, offset + SUBVER_OFFSET);
            }
            else
            {
                ReceivingAddress = NetworkAddress.IPv6Any;
            }
            if (Version >= 209)
            {
                StartHeight = buffer.ReadUInt32(offset + STARTHEIGHT_OFFSET);
            }

            ByteSize = CalculateByteSize();
        }
        public AlertPayload(VarString message, VarString signature)
        {
            Contract.Requires<ArgumentNullException>(message != null, "message");
            Contract.Requires<ArgumentNullException>(signature != null, "signature");

            Message = message;
            Signature = signature;

            ByteSize = Message.ByteSize + Signature.ByteSize;
        }
        public AlertPayload(VarString message, VarString signature)
        {
            Contract.Requires <ArgumentNullException>(message != null, "message");
            Contract.Requires <ArgumentNullException>(signature != null, "signature");

            Message   = message;
            Signature = signature;

            ByteSize = Message.ByteSize + Signature.ByteSize;
        }
        public AlertPayload(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires<ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires<ArgumentException>(buffer.Length >= AlertPayload.MinimumByteSize, "buffer");
            Contract.Requires<ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires<ArgumentOutOfRangeException>(offset <= buffer.Length - AlertPayload.MinimumByteSize, "offset");

            Message = new VarString(buffer, offset);
            Signature = new VarString(buffer, offset + (int)Message.ByteSize);

            ByteSize = Message.ByteSize + Signature.ByteSize;
        }
        public AlertPayload(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires <ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires <ArgumentException>(buffer.Length >= AlertPayload.MinimumByteSize, "buffer");
            Contract.Requires <ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires <ArgumentOutOfRangeException>(offset <= buffer.Length - AlertPayload.MinimumByteSize, "offset");

            Message   = new VarString(buffer, offset);
            Signature = new VarString(buffer, offset + (int)Message.ByteSize);

            ByteSize = Message.ByteSize + Signature.ByteSize;
        }
Exemple #7
0
        public VersionPayload(uint version, Services services, ulong timestamp, NetworkAddress emittingAddress,
                              NetworkAddress receivingAddress, ulong nonce, VarString subVersionNum, uint startHeight)
        {
            Contract.Requires <ArgumentNullException>(emittingAddress != null);
            Contract.Requires <ArgumentNullException>(receivingAddress != null);

            Version          = version;
            Services         = services;
            Timestamp        = timestamp;
            EmittingAddress  = emittingAddress;
            ReceivingAddress = receivingAddress;
            Nonce            = nonce;
            SubVersionNum    = subVersionNum;
            StartHeight      = startHeight;

            ByteSize = CalculateByteSize();
        }
        public VersionPayload(uint version, Services services, ulong timestamp, NetworkAddress emittingAddress,
            NetworkAddress receivingAddress, ulong nonce, VarString subVersionNum, uint startHeight)
        {
            Contract.Requires<ArgumentNullException>(emittingAddress != null);
            Contract.Requires<ArgumentNullException>(receivingAddress != null);

            Version = version;
            Services = services;
            Timestamp = timestamp;
            EmittingAddress = emittingAddress;
            ReceivingAddress = receivingAddress;
            Nonce = nonce;
            SubVersionNum = subVersionNum;
            StartHeight = startHeight;

            ByteSize = CalculateByteSize();
        }