Ejemplo n.º 1
0
        public AddrPayload(TimestampedNetworkAddress[] addressList)
        {
            Contract.Requires <ArgumentNullException>(addressList != null);

            AddressList = new VarArray <TimestampedNetworkAddress>(addressList);

            ByteSize = AddressList.ByteSize;
        }
Ejemplo n.º 2
0
        public GetDataPayload(InventoryVector[] inventory)
        {
            Contract.Requires <ArgumentNullException>(inventory != null, "inventory");

            Inventory = new VarArray <InventoryVector>(inventory);

            ByteSize = Inventory.ByteSize;
        }
Ejemplo n.º 3
0
        public HeadersPayload(Block[] headers, bool autoConvertBlocksToHeaders)
        {
            if (autoConvertBlocksToHeaders)
            {
                headers = (from b in headers select b.ConvertToBlockHeader()).ToArray();
            }
            Headers = new VarArray <Block>(headers);

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

            Inventory = new VarArray <InventoryVector>(buffer, offset);

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

            Headers = new VarArray <Block>(buffer, offset);

            ByteSize = Headers.ByteSize;
        }
Ejemplo n.º 6
0
        public GetHeadersPayload(uint version, Hash[] hashStart, Hash hashStop)
        {
            Contract.Requires <ArgumentNullException>(hashStart != null, "hashStart");
            Contract.Requires <ArgumentNullException>(hashStop != null, "hashStop");

            Version    = version;
            HashStart  = new VarArray <Hash>(hashStart);
            StartCount = new VarInt((uint)hashStart.Length);
            HashStop   = hashStop;

            ByteSize = Version.ByteSize() + StartCount.ByteSize + HashStart.ByteSize + HashStop.ByteSize;
        }
Ejemplo n.º 7
0
        public Tx(uint version, TxIn[] txIn, TxOut[] txOut, uint lockTime)
        {
            Contract.Requires <ArgumentNullException>(txIn != null, "txIn");
            Contract.Requires <ArgumentNullException>(txOut != null, "txOut");

            Version  = version;
            TxIns    = new VarArray <TxIn>(txIn);
            TxOuts   = new VarArray <TxOut>(txOut);
            LockTime = lockTime;

            ByteSize = Version.ByteSize() + TxIns.ByteSize + TxOuts.ByteSize + LockTime.ByteSize();
        }
Ejemplo n.º 8
0
        public Block(uint version, Hash previousBlock, Hash merkleRoot, uint timestamp, uint bits, uint nonce, VarArray <Tx> transactions)
        {
            Contract.Requires <ArgumentNullException>(previousBlock != null);
            Contract.Requires <ArgumentNullException>(merkleRoot != null);

            Version       = version;
            PreviousBlock = previousBlock;
            MerkleRoot    = merkleRoot;
            Timestamp     = Timestamp;
            Bits          = bits;
            Nonce         = nonce;
            Transactions  = transactions;
        }
Ejemplo n.º 9
0
        public GetHeadersPayload(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires <ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires <ArgumentException>(buffer.Length >= GetHeadersPayload.MinimumByteSize, "buffer");
            Contract.Requires <ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires <ArgumentOutOfRangeException>(offset <= buffer.Length - GetHeadersPayload.MinimumByteSize, "offset");

            Version    = buffer.ReadUInt32(offset);
            StartCount = new VarInt(buffer, StartCount_Offset(ref offset));
            HashStart  = new VarArray <Hash>(buffer, HashStart_Offset(ref offset));
            HashStop   = new Hash(buffer, HashStop_Offset(ref offset));

            ByteSize = Version.ByteSize() + StartCount.ByteSize + HashStart.ByteSize + HashStop.ByteSize;
        }
Ejemplo n.º 10
0
        public Tx(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires <ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires <ArgumentException>(buffer.Length >= Tx.MinimumByteSize, "buffer");
            Contract.Requires <ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires <ArgumentOutOfRangeException>(offset <= buffer.Length - Tx.MinimumByteSize, "offset");

            Version  = buffer.ReadUInt32(offset);
            TxIns    = new VarArray <TxIn>(buffer, TxIns_Offset(ref offset));
            TxOuts   = new VarArray <TxOut>(buffer, TxOuts_Offset(ref offset));
            LockTime = buffer.ReadUInt32(LockTime_Offset(ref offset));

            ByteSize = Version.ByteSize() + TxIns.ByteSize + TxOuts.ByteSize + LockTime.ByteSize();
        }
Ejemplo n.º 11
0
        public Block(byte[] buffer, int offset)
            : base(buffer, offset)
        {
            Contract.Requires <ArgumentNullException>(buffer != null, "buffer");
            Contract.Requires <ArgumentException>(buffer.Length > Block.MinimumByteSize, "buffer");
            Contract.Requires <ArgumentOutOfRangeException>(offset >= 0, "offset");
            Contract.Requires <ArgumentOutOfRangeException>(offset < buffer.Length - Block.MinimumByteSize, "offset");

            Version       = buffer.ReadUInt32(offset);
            PreviousBlock = new Hash(buffer, PreviousBlock_Offset(ref offset));
            MerkleRoot    = new Hash(buffer, MerkleRoot_Offset(ref offset));
            Timestamp     = buffer.ReadUInt32(Timestamp_Offset(ref offset));
            Bits          = buffer.ReadUInt32(Bits_Offset(ref offset));
            Nonce         = buffer.ReadUInt32(Nonce_Offset(ref offset));
            Transactions  = new VarArray <Tx>(buffer, Transactions_Offset(ref offset));
        }
Ejemplo n.º 12
0
        public AddrPayload(byte[] buffer, int offset)
        {
            AddressList = new VarArray <TimestampedNetworkAddress>(buffer, offset);

            ByteSize = AddressList.ByteSize;
        }