Skip to content

Commit

Permalink
Fix the height to end with (neo-project#88)
Browse files Browse the repository at this point in the history
* Fix-heightToEnd

* Minor fix and comment
  • Loading branch information
superboyiii authored and 陈志同 committed Oct 13, 2020
1 parent 3322316 commit 216431d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CoreMetrics/CoreMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private JObject GetBlocksTime(uint nBlocks, uint lastHeight)
if (nBlocks >= Blockchain.Singleton.Height)
{
JObject json = new JObject();
return json["error"] = "Requested number of blocks timestamps exceeds quantity of known blocks " + Blockchain.Singleton.Height;
return json["error"] = "Requested number of blocks timestamps " + nBlocks + " exceeds quantity of known blocks " + Blockchain.Singleton.Height;
}

if (nBlocks <= 0)
Expand All @@ -74,8 +74,8 @@ private JObject GetBlocksTime(uint nBlocks, uint lastHeight)
}

JArray array = new JArray();
uint heightToBegin = lastHeight > 0 ? lastHeight - nBlocks : Blockchain.Singleton.Height - nBlocks;
for (uint i = heightToBegin; i <= Blockchain.Singleton.HeaderHeight; i++)
uint heightToBegin = lastHeight > 0 ? lastHeight - nBlocks : (Blockchain.Singleton.Height - 1) - nBlocks;
for (uint i = heightToBegin; i <= heightToBegin + nBlocks; i++)
{
JObject json = new JObject();
Header header = Blockchain.Singleton.Store.GetHeader(i);
Expand Down

0 comments on commit 216431d

Please sign in to comment.