From: CryptoManiac Date: Wed, 9 Sep 2015 21:36:28 +0000 (+0300) Subject: Flush cursor item directrly to resolve syncronization issues. Not so fast, but at... X-Git-Url: https://git.novaco.in/?p=NovacoinLibrary.git;a=commitdiff_plain;h=7b349e848699cdb1701a69350b4f677a43831931 Flush cursor item directrly to resolve syncronization issues. Not so fast, but at least it works well. TODO: A proper delayed item update implementation. --- 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)