Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to iterate buffer #1726

Merged
merged 4 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/neo/SmartContract/ApplicationEngine.Iterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal IIterator CreateIterator(StackItem item)
{
Array array => new ArrayWrapper(array),
Map map => new MapWrapper(map),
VM.Types.Buffer buffer => new ByteArrayWrapper(buffer),
PrimitiveType primitive => new ByteArrayWrapper(primitive),
_ => throw new ArgumentException()
};
Expand Down
6 changes: 6 additions & 0 deletions src/neo/SmartContract/Iterators/ByteArrayWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Neo.VM;
using Neo.VM.Types;
using System;

Expand All @@ -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()
Expand Down