upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp97
1 files changed, 16 insertions, 81 deletions
diff --git a/src/db.cpp b/src/db.cpp
index de71a57..199fa44 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -392,77 +392,8 @@ bool CTxDB::LoadBlockIndex()
392 392
393 393
394 394
395// 395// Legacy IP-based peer address database (CAddrDB / addr.dat) removed --
396// CAddrDB 396// peer discovery is entirely Nostr/.btf-based now.
397//
398
399bool CAddrDB::WriteAddress(const CAddress& addr)
400{
401 return Write(make_pair(string("addr"), addr.GetKey()), addr);
402}
403
404bool CAddrDB::LoadAddresses()
405{
406 CRITICAL_BLOCK(cs_mapAddresses)
407 {
408 // Load user provided addresses
409 CAutoFile filein = fopen("addr.txt", "rt");
410 if (filein)
411 {
412 try
413 {
414 char psz[1000];
415 while (fgets(psz, sizeof(psz), filein))
416 {
417 CAddress addr(psz, NODE_NETWORK);
418 if (addr.ip != 0)
419 AddAddress(*this, addr);
420 }
421 }
422 catch (...) { }
423 }
424
425 // Get cursor
426 Dbc* pcursor = GetCursor();
427 if (!pcursor)
428 return false;
429
430 loop
431 {
432 // Read next record
433 CDataStream ssKey;
434 CDataStream ssValue;
435 int ret = ReadAtCursor(pcursor, ssKey, ssValue);
436 if (ret == DB_NOTFOUND)
437 break;
438 else if (ret != 0)
439 return false;
440
441 // Unserialize
442 string strType;
443 ssKey >> strType;
444 if (strType == "addr")
445 {
446 CAddress addr;
447 ssValue >> addr;
448 mapAddresses.insert(make_pair(addr.GetKey(), addr));
449 }
450 }
451
452 //// debug print
453 printf("mapAddresses:\n");
454 foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)
455 item.second.print();
456 printf("-----\n");
457 }
458
459 return true;
460}
461
462bool LoadAddresses()
463{
464 return CAddrDB("cr+").LoadAddresses();
465}
466 397
467 398
468 399
@@ -563,24 +494,28 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
563 { 494 {
564 string strKey; 495 string strKey;
565 ssKey >> strKey; 496 ssKey >> strKey;
566 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
567 if (strKey == "nTransactionFee") ssValue >> nTransactionFee; 497 if (strKey == "nTransactionFee") ssValue >> nTransactionFee;
568 if (strKey == "addrIncoming") ssValue >> addrIncoming; 498 if (strKey == "addrIncoming") ssValue >> addrIncoming;
569 if (strKey == "nMineMode") ssValue >> nMineMode; 499 // Mining-mode/pool settings (nMineMode, strParticipantPool, strPoolName,
570 if (strKey == "strParticipantPool") ssValue >> strParticipantPool; 500 // strPoolDashboardUrl, dPoolFeePercent, fGenerateBitcoins) are intentionally
571 if (strKey == "strPoolName") ssValue >> strPoolName; 501 // NOT restored here. They used to be, and LoadWallet() runs after CLI flags
572 if (strKey == "strPoolDashboardUrl") ssValue >> strPoolDashboardUrl; 502 // are parsed in main_gui.cpp, so a saved value would silently overwrite
573 if (strKey == "dPoolFeePercent") ssValue >> dPoolFeePercent; 503 // whatever was just requested on the command line or in a previous Options
504 // session -- no error, no log line. That's what caused pool name/address to
505 // show correctly in the UI but stay stale in the logs, and mode to change
506 // behavior across restarts. Mode/pool config is decided fresh every launch
507 // instead: CLI flags if given, otherwise the compiled-in default. Nothing to
508 // go stale, nothing to fight over load order.
574 } 509 }
575 } 510 }
576 } 511 }
577 512
578 printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
579 printf("nTransactionFee = %lld\n", nTransactionFee); 513 printf("nTransactionFee = %lld\n", nTransactionFee);
580 printf("addrIncoming = %s\n", addrIncoming.ToString().c_str()); 514 printf("addrIncoming = %s\n", addrIncoming.ToString().c_str());
581 printf("nMineMode = %d, strParticipantPool = %s\n", nMineMode, strParticipantPool.c_str()); 515 printf("nMineMode = %d, strParticipantPool = %s, fGenerateBitcoins = %d (from CLI/default, not wallet.dat)\n",
582 printf("strPoolName = %s, dPoolFeePercent = %.2f\n", strPoolName.c_str(), dPoolFeePercent); 516 nMineMode, strParticipantPool.c_str(), fGenerateBitcoins);
583 printf("strPoolDashboardUrl = %s\n", strPoolDashboardUrl.c_str()); 517 printf("strPoolName = %s, dPoolFeePercent = %.2f, strPoolDashboardUrl = %s (from CLI/default, not wallet.dat)\n",
518 strPoolName.c_str(), dPoolFeePercent, strPoolDashboardUrl.c_str());
584 519
585 return true; 520 return true;
586} 521}