diff --git a/source/jaindb/BlockChain.cs b/source/jaindb/BlockChain.cs index dbd570d..ad63906 100644 --- a/source/jaindb/BlockChain.cs +++ b/source/jaindb/BlockChain.cs @@ -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, @@ -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; } diff --git a/source/jaindb/jaindb.cs b/source/jaindb/jaindb.cs index 3f8dca5..b706062 100644 --- a/source/jaindb/jaindb.cs +++ b/source/jaindb/jaindb.cs @@ -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 { } diff --git a/source/jaindb/jaindb.csproj b/source/jaindb/jaindb.csproj index 91d26bd..c7dba45 100644 --- a/source/jaindb/jaindb.csproj +++ b/source/jaindb/jaindb.csproj @@ -13,8 +13,8 @@ https://github.com/rzander/jaindb blockchain json 1.0.1 - 1.0.1.79 - 1.0.1.79 + 1.0.1.81 + 1.0.1.81 fcfd6c0a-e53c-46cb-8a9d-b786c0579861 JainDB_Logo.ico