From 55d65e32caf60b5baa4e1a97d1e240c4adb0dd01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 19:26:19 +0200 Subject: [PATCH 01/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a327cca4c..b7c48332a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3196,7 +3196,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl { uint8_t pubkey33[33]; // Check timestamp - if ( 0 ) + if ( 1 ) { uint256 hash; int32_t i; hash = blockhdr.GetHash(); From 6460b5b19ca18c6298188df4aba9b616a77592f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 19:38:59 +0200 Subject: [PATCH 02/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b7c48332a..37804da3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -383,7 +383,7 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { ProcessBlockAvailability(nodeid); BlockMap::iterator it = mapBlockIndex.find(hash); - if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { + if (it != 0 && it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; From da7775433d1ae81cc49570384d2d180700bc85a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 19:40:37 +0200 Subject: [PATCH 03/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 37804da3e..b7c48332a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -383,7 +383,7 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { ProcessBlockAvailability(nodeid); BlockMap::iterator it = mapBlockIndex.find(hash); - if (it != 0 && it != mapBlockIndex.end() && it->second->nChainWork > 0) { + if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; From 0a0ec219d79db1d26d2d37ee0103f07e45fc796a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 19:44:40 +0200 Subject: [PATCH 04/11] Test --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b7c48332a..1bcde7710 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -382,12 +382,13 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { ProcessBlockAvailability(nodeid); - BlockMap::iterator it = mapBlockIndex.find(hash); + /*BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; - } else { + } else*/ + { // An unknown block was announced; just assume that the latest one is the best one. state->hashLastUnknownBlock = hash; } From 944bf4b0913b4bd535c7595acef20ac27188ad93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 19:57:18 +0200 Subject: [PATCH 05/11] Test --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1bcde7710..54683db07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -367,7 +367,8 @@ void ProcessBlockAvailability(NodeId nodeid) { if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); - if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { + if (itOld != 0 && itOld->second != 0 && itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) + { if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; state->hashLastUnknownBlock.SetNull(); From 9b7233cf170c1149fbcbc149b488657285f90893 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 19:58:23 +0200 Subject: [PATCH 06/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 54683db07..47417e894 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -367,7 +367,7 @@ void ProcessBlockAvailability(NodeId nodeid) { if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); - if (itOld != 0 && itOld->second != 0 && itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) + if (itOld->second != 0 && itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; From a2f017de0858621c2274c788596dfff9a49b23ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 20:05:02 +0200 Subject: [PATCH 07/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 47417e894..30e3ab5cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -381,7 +381,7 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { CNodeState *state = State(nodeid); assert(state != NULL); - ProcessBlockAvailability(nodeid); + //ProcessBlockAvailability(nodeid); /*BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { From 88e117ada6716eecfac0352d8fe89395789dece5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 20:09:07 +0200 Subject: [PATCH 08/11] Test --- src/arith_uint256.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index 2e6136357..be1a44bba 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -109,6 +109,11 @@ base_uint& base_uint::operator/=(const base_uint& b) template int base_uint::CompareTo(const base_uint& b) const { + if ( pn == 0 || b.pn == 0 ) + { + fprintf(stderr,"CompareTo null %p or %p\n",pn,b.pn); + return(0); + } for (int i = WIDTH - 1; i >= 0; i--) { if (pn[i] < b.pn[i]) return -1; From 110696f9e17b4a42303dd6839a9cee11cd95ffb2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 20:09:55 +0200 Subject: [PATCH 09/11] Test --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 30e3ab5cb..bf57f8cb2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -367,7 +367,7 @@ void ProcessBlockAvailability(NodeId nodeid) { if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); - if (itOld->second != 0 && itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) + if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; @@ -381,14 +381,14 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { CNodeState *state = State(nodeid); assert(state != NULL); - //ProcessBlockAvailability(nodeid); + ProcessBlockAvailability(nodeid); - /*BlockMap::iterator it = mapBlockIndex.find(hash); + BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; - } else*/ + } else { // An unknown block was announced; just assume that the latest one is the best one. state->hashLastUnknownBlock = hash; From e4f53bd20a5b8231e8d0cce2075759df50cc8822 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 20:23:25 +0200 Subject: [PATCH 10/11] Test --- src/arith_uint256.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index be1a44bba..a1865b649 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -109,7 +109,7 @@ base_uint& base_uint::operator/=(const base_uint& b) template int base_uint::CompareTo(const base_uint& b) const { - if ( pn == 0 || b.pn == 0 ) + if ( (uint64_t)pn < 0x1000 || (uint64_t)b.pn <= 0x1000 ) { fprintf(stderr,"CompareTo null %p or %p\n",pn,b.pn); return(0); From e40b78e93c84dc2506add49cb8a8b5a1fc6f6f62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 20:47:47 +0200 Subject: [PATCH 11/11] Crash fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index bf57f8cb2..777926200 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3198,7 +3198,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl { uint8_t pubkey33[33]; // Check timestamp - if ( 1 ) + if ( 0 ) { uint256 hash; int32_t i; hash = blockhdr.GetHash();