Use byte[] instead of IEnumerable<byte> if possible
[NovacoinLibrary.git] / Novacoin / COutPoint.cs
index 4c9f17a..be3017f 100644 (file)
@@ -1,8 +1,24 @@
-\feffusing System;
+\feff/**
+ *  Novacoin classes library
+ *  Copyright (C) 2015 Alex D. (balthazar.ad@gmail.com)
+
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License, or (at your option) any later version.
+
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Text;
-using System.Threading.Tasks;
 
 namespace Novacoin
 {
@@ -36,10 +52,10 @@ namespace Novacoin
             n = o.n;
         }
 
-        public COutPoint(IEnumerable<byte> bytes)
+        public COutPoint(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, 32);
         }
 
         public bool IsNull
@@ -51,7 +67,7 @@ namespace Novacoin
         {
             get
             {
-                List<byte> r = new List<byte>();
+                var r = new List<byte>();
                 r.AddRange(hash.hashBytes);
                 r.AddRange(BitConverter.GetBytes(n));
 
@@ -61,7 +77,7 @@ namespace Novacoin
 
         public override string ToString()
         {
-            StringBuilder sb = new StringBuilder();
+            var sb = new StringBuilder();
             sb.AppendFormat("COutPoint({0}, {1})", hash.ToString(), n);
 
             return sb.ToString();