Skip to content

Commit

Permalink
Prevent exceed the height (neo-project#92)
Browse files Browse the repository at this point in the history
* Update CoreMetrics.cs

I think that it could be exceeded the max height using the `lastHeight` parameter

* Update CoreMetrics.cs
  • Loading branch information
shargon authored and 陈志同 committed Oct 13, 2020
1 parent eb505b9 commit 4ff8a18
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions CoreMetrics/CoreMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ namespace Neo.Plugins
{
public class CoreMetrics : Plugin, IRpcPlugin
{
public override void Configure()
{
}
public override void Configure() { }

public void PreProcess(HttpContext context, string method, JArray _params)
{
}
public void PreProcess(HttpContext context, string method, JArray _params) { }

public JObject OnProcess(HttpContext context, string method, JArray _params)
{
Expand All @@ -32,9 +28,7 @@ public JObject OnProcess(HttpContext context, string method, JArray _params)
}
}

public void PostProcess(HttpContext context, string method, JArray _params, JObject result)
{
}
public void PostProcess(HttpContext context, string method, JArray _params, JObject result) { }

private JObject GetBlocksTime(uint nBlocks, uint lastHeight)
{
Expand Down Expand Up @@ -79,6 +73,8 @@ private JObject GetBlocksTime(uint nBlocks, uint lastHeight)
{
JObject json = new JObject();
Header header = Blockchain.Singleton.Store.GetHeader(i);
if (header == null) break;

json["timestamp"] = header.Timestamp;
json["height"] = i;
array.Add(json);
Expand Down

0 comments on commit 4ff8a18

Please sign in to comment.