-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Iterator APIs and
StorageIterator
1. Add `Neo.Iterator.*` 1. Add `Neo.Storage.Find`
- Loading branch information
Erik Zhang
committed
Feb 5, 2018
1 parent
f0cf5cc
commit a234978
Showing
6 changed files
with
187 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Neo.VM; | ||
using System; | ||
|
||
namespace Neo.SmartContract | ||
{ | ||
internal abstract class Iterator : IDisposable, IInteropInterface | ||
{ | ||
public abstract void Dispose(); | ||
public abstract StackItem Key(); | ||
public abstract bool Next(); | ||
public abstract StackItem Value(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Neo.Core; | ||
using Neo.VM; | ||
using System.Collections.Generic; | ||
|
||
namespace Neo.SmartContract | ||
{ | ||
internal class StorageIterator : Iterator | ||
{ | ||
private readonly IEnumerator<KeyValuePair<StorageKey, StorageItem>> enumerator; | ||
|
||
public StorageIterator(IEnumerator<KeyValuePair<StorageKey, StorageItem>> enumerator) | ||
{ | ||
this.enumerator = enumerator; | ||
} | ||
|
||
public override void Dispose() | ||
{ | ||
enumerator.Dispose(); | ||
} | ||
|
||
public override StackItem Key() | ||
{ | ||
return enumerator.Current.Key.Key; | ||
} | ||
|
||
public override bool Next() | ||
{ | ||
return enumerator.MoveNext(); | ||
} | ||
|
||
public override StackItem Value() | ||
{ | ||
return enumerator.Current.Value.Value; | ||
} | ||
} | ||
} |