From 7b349e848699cdb1701a69350b4f677a43831931 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Thu, 10 Sep 2015 00:36:28 +0300 Subject: [PATCH] Flush cursor item directrly to resolve syncronization issues. Not so fast, but at least it works well. TODO: A proper delayed item update implementation. --- Novacoin/CBlockStore.cs | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/Novacoin/CBlockStore.cs b/Novacoin/CBlockStore.cs index e8981eb..f44a93d 100644 --- a/Novacoin/CBlockStore.cs +++ b/Novacoin/CBlockStore.cs @@ -208,6 +208,9 @@ namespace Novacoin // Load data about the top node. ChainParams = dbConn.Table().First(); + + genesisBlockCursor = dbConn.Query("select * from [BlockStorage] where [Hash] = ?", (byte[])NetInfo.nHashGenesisBlock).First(); + bestBlockCursor = dbConn.Query("select * from [BlockStorage] where [Hash] = ?", ChainParams.HashBestChain).First(); } } @@ -472,6 +475,11 @@ namespace Novacoin nTimeBestReceived = Interop.GetTime(); nTransactionsUpdated++; + if (!UpdateTopChain(cursor)) + { + return false; // unable to set top chain node. + } + return true; } @@ -613,7 +621,13 @@ namespace Novacoin } // Add to current best branch - cursor.prev.next = cursor; + var prevCursor = cursor.prev; + prevCursor.next = cursor; + + if (!UpdateDBCursor(ref prevCursor)) + { + return false; // unable to update + } // Delete redundant memory transactions foreach (var tx in block.vtx) -- 1.7.1