Skip to content

Commit

Permalink
added block_hash to getblockids call
Browse files Browse the repository at this point in the history
  • Loading branch information
merl111 committed Aug 10, 2020
1 parent b8ac0a3 commit d409e93
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions EventTracker/EventTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using Neo.Wallets;
using Microsoft.AspNetCore.Http;
using Neo.Network.P2P.Payloads;
using System.Threading.Tasks;
using MongoDB.Bson.Serialization;

namespace Neo.Plugins
{
Expand Down Expand Up @@ -111,13 +109,24 @@ private JObject HandleGetBlockIds(JArray _params)

var filter = builder.And(filters);
var sort = Builders<BsonDocument>.Sort.Ascending("block_index");
var blockIds = collection.Distinct<ulong>("block_index", filter).ToList().OrderBy(x => x);
//var blockIds = collection.Distinct<ulong>("block_index", filter);//.ToDictionary(x => x.).OrderBy(x => x);
var blockIds = new Dictionary<ulong,string>();

collection.Aggregate().Group(new BsonDocument("_id", new BsonDocument {
{"block_index", "$block_index"},
{"block_hash", "$block_hash"}
})).ToList().ForEach(
doc => {
var data = doc["_id"];
blockIds.Add((ulong)data["block_index"].AsInt32, data["block_hash"].AsString);
});

var objects = new JArray();
foreach (var id in blockIds)
foreach (var entry in blockIds)
{
JObject item = new JObject();
item["block_index"] = id;
item["block_index"] = entry.Key;
item["block_hash"] = entry.Value;

objects.Add(item);
}
Expand Down

0 comments on commit d409e93

Please sign in to comment.