From 242e1c580f315469f132dbdd10994e001e611c5d Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 23 Jun 2020 12:02:28 +0200 Subject: [PATCH 1/3] Buffer iterator --- src/neo/SmartContract/ApplicationEngine.Iterator.cs | 1 + src/neo/SmartContract/Iterators/ByteArrayWrapper.cs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/neo/SmartContract/ApplicationEngine.Iterator.cs b/src/neo/SmartContract/ApplicationEngine.Iterator.cs index 26ea78d695..62ecfeec07 100644 --- a/src/neo/SmartContract/ApplicationEngine.Iterator.cs +++ b/src/neo/SmartContract/ApplicationEngine.Iterator.cs @@ -20,6 +20,7 @@ internal IIterator CreateIterator(StackItem item) { Array array => new ArrayWrapper(array), Map map => new MapWrapper(map), + Buffer array => new ByteArrayWrapper(array), PrimitiveType primitive => new ByteArrayWrapper(primitive), _ => throw new ArgumentException() }; diff --git a/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs b/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs index c60c839543..f02961b8d7 100644 --- a/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs +++ b/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs @@ -1,3 +1,4 @@ +using Neo.VM; using Neo.VM.Types; using System; @@ -13,6 +14,11 @@ public ByteArrayWrapper(PrimitiveType value) this.array = value.Span.ToArray(); } + public ByteArrayWrapper(VM.Types.Buffer value) + { + this.array = value.GetSpan().ToArray(); + } + public void Dispose() { } public PrimitiveType Key() From 7149317706c5b4f069ed0d72a8fb399954ae9b25 Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 23 Jun 2020 12:03:40 +0200 Subject: [PATCH 2/3] Rename --- src/neo/SmartContract/ApplicationEngine.Iterator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neo/SmartContract/ApplicationEngine.Iterator.cs b/src/neo/SmartContract/ApplicationEngine.Iterator.cs index 62ecfeec07..c902c50979 100644 --- a/src/neo/SmartContract/ApplicationEngine.Iterator.cs +++ b/src/neo/SmartContract/ApplicationEngine.Iterator.cs @@ -20,7 +20,7 @@ internal IIterator CreateIterator(StackItem item) { Array array => new ArrayWrapper(array), Map map => new MapWrapper(map), - Buffer array => new ByteArrayWrapper(array), + VM.Types.Buffer buffer => new ByteArrayWrapper(buffer), PrimitiveType primitive => new ByteArrayWrapper(primitive), _ => throw new ArgumentException() }; From d3145714adbfc13776c3affc08e843b61d8d710f Mon Sep 17 00:00:00 2001 From: erikzhang Date: Tue, 23 Jun 2020 20:07:22 +0800 Subject: [PATCH 3/3] Remove using --- src/neo/SmartContract/Iterators/ByteArrayWrapper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs b/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs index d4f03befd8..c26ca2b0e1 100644 --- a/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs +++ b/src/neo/SmartContract/Iterators/ByteArrayWrapper.cs @@ -1,4 +1,3 @@ -using Neo.VM; using Neo.VM.Types; using System;