Skip to content

Commit

Permalink
Fix Display Issue where the _index can be from an older block with sa…
Browse files Browse the repository at this point in the history
…me hash
  • Loading branch information
rzander committed Oct 30, 2018
1 parent 20a255a commit 0b52d6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions source/jaindb/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public block MineNewBlock(block ParentBlock, string Blocktype = "")

var oNew = new block()
{
index = iIndex,
index = ParentBlock.index + 1,
timestamp = DateTime.Now.Ticks,
previous_hash = ParentBlock.hash,
blocktype = Blocktype,
Expand Down Expand Up @@ -219,7 +219,7 @@ public block GetLastBlock(string blockType = "")

//return genesis block if no other block was found
if (oBlock == null)
return GetBlock(0);
return GetBlock(0, "root");
else
return oBlock;
}
Expand Down
4 changes: 4 additions & 0 deletions source/jaindb/jaindb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,10 @@ public static JObject GetFull(string DeviceID, int Index = -1, string blockType
oInv.Add(new JProperty("_date", oRaw["_date"]));
if (oInv["_hash"] == null)
oInv.Add(new JProperty("_hash", oRaw["_hash"]));

//Set index and date from blockchain as the index and hash can be from a previous block
oInv["_index"] = oRaw["_index"];
oInv["_date"] = oRaw["_inventoryDate"];
}
catch { }

Expand Down
4 changes: 2 additions & 2 deletions source/jaindb/jaindb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<RepositoryUrl>https://github.com/rzander/jaindb</RepositoryUrl>
<PackageTags>blockchain json</PackageTags>
<Version>1.0.1</Version>
<AssemblyVersion>1.0.1.79</AssemblyVersion>
<FileVersion>1.0.1.79</FileVersion>
<AssemblyVersion>1.0.1.81</AssemblyVersion>
<FileVersion>1.0.1.81</FileVersion>
<StartupObject></StartupObject>
<UserSecretsId>fcfd6c0a-e53c-46cb-8a9d-b786c0579861</UserSecretsId>
<ApplicationIcon>JainDB_Logo.ico</ApplicationIcon>
Expand Down

0 comments on commit 0b52d6d

Please # to comment.