Removal of excessive handling code
authorCryptoManiac <balthazar@yandex.ru>
Sat, 15 Aug 2015 16:26:01 +0000 (19:26 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Sat, 15 Aug 2015 16:26:01 +0000 (19:26 +0300)
Novacoin/CScript.cs
Novacoin/WrappedList.cs

index 9ada832..a6f16a2 100644 (file)
@@ -135,24 +135,17 @@ namespace Novacoin
                public override string ToString()
                {
                        StringBuilder sb = new StringBuilder();
-
             WrappedList<byte> wCodeBytes = new WrappedList<byte>(codeBytes);
 
-            while (wCodeBytes.ItemsLeft > 0)
+            opcodetype opcode; // Current opcode
+            IEnumerable<byte> pushArgs; // OP_PUSHDATAn argument
+            while (ScriptOpcode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
             {
                 if (sb.Length != 0)
                 {
                     sb.Append(" ");
                 }
 
-                opcodetype opcode;
-                IEnumerable<byte> pushArgs;
-                if (!ScriptOpcode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
-                {
-                    sb.Append("[error]");
-                    break;
-                }
-
                 if (0 <= opcode && opcode <= opcodetype.OP_PUSHDATA4)
                 {
                     sb.Append(ScriptOpcode.ValueString(pushArgs));
index e871025..79068c3 100644 (file)
@@ -28,11 +28,6 @@ namespace Novacoin
         private int Index;
         private List<T> Elements;
 
-        public int ItemsLeft
-        {
-            get { return Elements.Count - Index; }
-        }
-
         public WrappedList(IList<T> List, int Start)
         {
             Elements = new List<T>(List);
@@ -57,7 +52,7 @@ namespace Novacoin
 
         public T[] GetItems(int Count)
         {
-            if (ItemsLeft < Count)
+            if (Elements.Count - Index < Count)
             {
                 throw new WrappedListException("Unable to read requested amount of data.");
             }