Skip to content

Commit

Permalink
Extend the return value of GetRequestsByUrl (neo-project#2091)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommo-L authored and Shawn committed Jan 8, 2021
1 parent a2ca5b1 commit 9062a74
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/neo/SmartContract/Native/Oracle/OracleContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ public OracleRequest GetRequest(StoreView snapshot, ulong id)
return snapshot.Storages.Find(new KeyBuilder(Id, Prefix_Request).ToArray()).Select(p => (BitConverter.ToUInt64(p.Key.Key, 1), p.Value.GetInteroperable<OracleRequest>()));
}

public IEnumerable<OracleRequest> GetRequestsByUrl(StoreView snapshot, string url)
public IEnumerable<(ulong, OracleRequest)> GetRequestsByUrl(StoreView snapshot, string url)
{
IdList list = snapshot.Storages.TryGet(CreateStorageKey(Prefix_IdList).Add(GetUrlHash(url)))?.GetInteroperable<IdList>();
if (list is null) yield break;
foreach (ulong id in list)
yield return snapshot.Storages[CreateStorageKey(Prefix_Request).Add(id)].GetInteroperable<OracleRequest>();
yield return (id, snapshot.Storages[CreateStorageKey(Prefix_Request).Add(id)].GetInteroperable<OracleRequest>());
}

private static byte[] GetUrlHash(string url)
Expand Down

0 comments on commit 9062a74

Please sign in to comment.