upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/db.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 3af87fb..7763af8 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -551,6 +551,9 @@ bool CReviewDB::WriteReviews(uint256 hash, const vector<CReview>& vReviews)
551 551
552bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet) 552bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
553{ 553{
554 // Whether wallet.dat actually carried a mining mode, as opposed to just the
555 // ancient fGenerateBitcoins flag. See the reconciliation further down.
556 bool fHaveStoredMineMode = false;
554 vchDefaultKeyRet.clear(); 557 vchDefaultKeyRet.clear();
555 558
556 // Satoshi's "todo: shouldn't we catch exceptions" sat here since 2009, and 559 // Satoshi's "todo: shouldn't we catch exceptions" sat here since 2009, and
@@ -669,7 +672,7 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
669 // participant cannot work without. 672 // participant cannot work without.
670 if (!fMineModeFromCommandLine) 673 if (!fMineModeFromCommandLine)
671 { 674 {
672 if (strKey == "nMineMode") ssValue >> nMineMode; 675 if (strKey == "nMineMode") { ssValue >> nMineMode; fHaveStoredMineMode = true; }
673 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins; 676 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
674 if (strKey == "strParticipantPool") ssValue >> strParticipantPool; 677 if (strKey == "strParticipantPool") ssValue >> strParticipantPool;
675 } 678 }
@@ -692,6 +695,32 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
692 return false; 695 return false;
693 } 696 }
694 697
698 // fGenerateBitcoins and nMineMode only mean anything together, and a
699 // wallet.dat can easily hold one without the other: Bitcoin 0.1.0 already
700 // wrote fGenerateBitcoins when mining was toggled, years before this fork
701 // had a mode at all. Restoring that lone flag put a node into the one state
702 // the miner cannot act on -- generate on, mode relay -- so every miner
703 // thread started and returned at the relay guard, and the machine sat there
704 // looking like it was mining while hashing nothing. That happened to a
705 // 32-core node on the first 1.2.11 start.
706 //
707 // So the flag is only believed when the mode it belongs to was stored with
708 // it, and the pair is made coherent either way.
709 if (!fMineModeFromCommandLine)
710 {
711 if (!fHaveStoredMineMode)
712 {
713 if (fGenerateBitcoins)
714 printf("LoadWallet: ignoring a stored fGenerateBitcoins with no mining mode "
715 "beside it -- it predates this setting and cannot be read on its own\n");
716 fGenerateBitcoins = 0;
717 }
718 else
719 {
720 fGenerateBitcoins = (nMineMode != MINE_RELAY) ? 1 : 0;
721 }
722 }
723
695 printf("nTransactionFee = %lld\n", nTransactionFee); 724 printf("nTransactionFee = %lld\n", nTransactionFee);
696 printf("addrIncoming = %s\n", addrIncoming.ToString().c_str()); 725 printf("addrIncoming = %s\n", addrIncoming.ToString().c_str());
697 printf("nMineMode = %d, strParticipantPool = %s, fGenerateBitcoins = %d (%s)\n", 726 printf("nMineMode = %d, strParticipantPool = %s, fGenerateBitcoins = %d (%s)\n",