public COutPoint(IEnumerable<byte> bytes)
{
- hash = new Hash256(bytes.Take(32));
- n = BitConverter.ToUInt32(bytes.Skip(32).Take(4).ToArray(), 0);
+ hash = new Hash256(bytes);
+ n = BitConverter.ToUInt32(bytes.ToArray(), 32);
}
public bool IsNull
-\feffusing System.Security.Cryptography;
+\feffusing System;
+using System.Security.Cryptography;
using System.Collections.Generic;
using System.Linq;
/// Initializes a new instance of Hash class with first 20 bytes from supplied list
/// </summary>
/// <param name="bytesList">List of bytes</param>
- public Hash(IEnumerable<byte> bytes)
+ public Hash(IEnumerable<byte> bytes, int skip = 0)
{
- _hashBytes = bytes.Take(hashSize).ToArray();
+ _hashBytes = bytes.Skip(skip).Take(hashSize).ToArray();
}
- public Hash(byte[] bytes)
+ public Hash(byte[] bytes, int offset = 0)
{
- _hashBytes = bytes;
+ _hashBytes = new byte[hashSize];
+ Array.Copy(bytes, offset, _hashBytes, 0, hashSize);
}
public Hash(Hash h)
}
public Hash160() : base() { }
- public Hash160(byte[] bytes) : base(bytes) { }
- public Hash160(IEnumerable<byte> bytes) : base(bytes) { }
+ public Hash160(byte[] bytes, int offset = 0) : base(bytes, offset) { }
+ public Hash160(IEnumerable<byte> bytes, int skip = 0) : base(bytes, skip) { }
public Hash160(Hash160 h) : base(h) { }
public static Hash160 Compute160(IEnumerable<byte> inputBytes)
}
public Hash256() : base() { }
- public Hash256(byte[] bytes) : base(bytes) { }
- public Hash256(IEnumerable<byte> bytes) : base(bytes) { }
+ public Hash256(byte[] bytes, int offset=0) : base(bytes, offset) { }
+ public Hash256(IEnumerable<byte> bytes, int skip=0) : base(bytes, skip) { }
public Hash256(Hash256 h) : base(h) { }
}
public ScryptHash256() : base() { }
- public ScryptHash256(byte[] bytes) : base(bytes) { }
- public ScryptHash256(IEnumerable<byte> bytes) : base(bytes) { }
+ public ScryptHash256(byte[] bytes, int offset = 0) : base(bytes, offset) { }
+ public ScryptHash256(IEnumerable<byte> bytes, int skip = 0) : base(bytes, skip) { }
public ScryptHash256(ScryptHash256 h) : base(h) { }
/// <summary>
throw new WrappedListException("Unable to read requested amount of data.");
}
- T[] result = Elements.Skip<T>(Index).Take<T>(Count).ToArray<T>();
+ T[] result = Elements.Skip(Index).Take(Count).ToArray();
Index += Count;
return result;
throw new WrappedListException("Unable to read requested amount of data.");
}
- T[] result = Elements.Skip<T>(Index).Take<T>(Count).ToArray<T>();
+ T[] result = Elements.Skip(Index).Take(Count).ToArray();
return result;
}
throw new WrappedListException("Unable to read requested amount of data.");
}
- IEnumerable<T> result = Elements.Skip<T>(Index).Take<T>(Count);
+ IEnumerable<T> result = Elements.Skip(Index).Take(Count);
Index += Count;
return result;