From: CryptoManiac Date: Sat, 15 Aug 2015 16:26:01 +0000 (+0300) Subject: Removal of excessive handling code X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=a7550e3f4bc1d00d0fdbae1fec7c7a5000c5cfea;p=NovacoinLibrary.git Removal of excessive handling code --- diff --git a/Novacoin/CScript.cs b/Novacoin/CScript.cs index 9ada832..a6f16a2 100644 --- a/Novacoin/CScript.cs +++ b/Novacoin/CScript.cs @@ -135,24 +135,17 @@ namespace Novacoin public override string ToString() { StringBuilder sb = new StringBuilder(); - WrappedList wCodeBytes = new WrappedList(codeBytes); - while (wCodeBytes.ItemsLeft > 0) + opcodetype opcode; // Current opcode + IEnumerable pushArgs; // OP_PUSHDATAn argument + while (ScriptOpcode.GetOp(ref wCodeBytes, out opcode, out pushArgs)) { if (sb.Length != 0) { sb.Append(" "); } - opcodetype opcode; - IEnumerable 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)); diff --git a/Novacoin/WrappedList.cs b/Novacoin/WrappedList.cs index e871025..79068c3 100644 --- a/Novacoin/WrappedList.cs +++ b/Novacoin/WrappedList.cs @@ -28,11 +28,6 @@ namespace Novacoin private int Index; private List Elements; - public int ItemsLeft - { - get { return Elements.Count - Index; } - } - public WrappedList(IList List, int Start) { Elements = new List(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."); }