Skip to content

Commit 0b52d6d

Browse files
committed
Fix Display Issue where the _index can be from an older block with same hash
1 parent 20a255a commit 0b52d6d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

source/jaindb/BlockChain.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public block MineNewBlock(block ParentBlock, string Blocktype = "")
148148

149149
var oNew = new block()
150150
{
151-
index = iIndex,
151+
index = ParentBlock.index + 1,
152152
timestamp = DateTime.Now.Ticks,
153153
previous_hash = ParentBlock.hash,
154154
blocktype = Blocktype,
@@ -219,7 +219,7 @@ public block GetLastBlock(string blockType = "")
219219

220220
//return genesis block if no other block was found
221221
if (oBlock == null)
222-
return GetBlock(0);
222+
return GetBlock(0, "root");
223223
else
224224
return oBlock;
225225
}

source/jaindb/jaindb.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,10 @@ public static JObject GetFull(string DeviceID, int Index = -1, string blockType
10071007
oInv.Add(new JProperty("_date", oRaw["_date"]));
10081008
if (oInv["_hash"] == null)
10091009
oInv.Add(new JProperty("_hash", oRaw["_hash"]));
1010+
1011+
//Set index and date from blockchain as the index and hash can be from a previous block
1012+
oInv["_index"] = oRaw["_index"];
1013+
oInv["_date"] = oRaw["_inventoryDate"];
10101014
}
10111015
catch { }
10121016

source/jaindb/jaindb.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<RepositoryUrl>https://github.com/rzander/jaindb</RepositoryUrl>
1414
<PackageTags>blockchain json</PackageTags>
1515
<Version>1.0.1</Version>
16-
<AssemblyVersion>1.0.1.79</AssemblyVersion>
17-
<FileVersion>1.0.1.79</FileVersion>
16+
<AssemblyVersion>1.0.1.81</AssemblyVersion>
17+
<FileVersion>1.0.1.81</FileVersion>
1818
<StartupObject></StartupObject>
1919
<UserSecretsId>fcfd6c0a-e53c-46cb-8a9d-b786c0579861</UserSecretsId>
2020
<ApplicationIcon>JainDB_Logo.ico</ApplicationIcon>

0 commit comments

Comments
 (0)