10
10
#include " init.h"
11
11
12
12
#include " addrman.h"
13
+ #include " db.h"
13
14
#include " rpcserver.h"
14
15
#include " checkpoints.h"
15
16
#include " miner.h"
16
17
#include " net.h"
17
18
#include " txdb.h"
18
19
#include " ui_interface.h"
19
20
#include " util.h"
21
+ #ifdef ENABLE_WALLET
20
22
#include " wallet.h"
21
23
#include " walletdb.h"
24
+ #endif
22
25
23
26
#include < inttypes.h>
24
27
#include < stdint.h>
35
38
using namespace std ;
36
39
using namespace boost ;
37
40
41
+ #ifdef ENABLE_WALLET
38
42
std::string strWalletFile;
39
43
CWallet* pwalletMain;
44
+ #endif
40
45
41
46
#ifdef WIN32
42
47
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
@@ -108,15 +113,19 @@ void Shutdown()
108
113
RenameThread (" bitcoin-shutoff" );
109
114
mempool.AddTransactionsUpdated (1 );
110
115
StopRPCThreads ();
116
+ #ifdef ENABLE_WALLET
111
117
ShutdownRPCMining ();
112
118
if (pwalletMain)
113
119
bitdb.Flush (false );
114
120
GenerateBitcoins (false , NULL , 0 );
121
+ #endif
115
122
StopNode ();
116
123
{
117
124
LOCK (cs_main);
125
+ #ifdef ENABLE_WALLET
118
126
if (pwalletMain)
119
127
pwalletMain->SetBestChain (chainActive.GetLocator ());
128
+ #endif
120
129
if (pblocktree)
121
130
pblocktree->Flush ();
122
131
if (pcoinsTip)
@@ -125,12 +134,16 @@ void Shutdown()
125
134
delete pcoinsdbview; pcoinsdbview = NULL ;
126
135
delete pblocktree; pblocktree = NULL ;
127
136
}
137
+ #ifdef ENABLE_WALLET
128
138
if (pwalletMain)
129
139
bitdb.Flush (true );
140
+ #endif
130
141
boost::filesystem::remove (GetPidFile ());
131
142
UnregisterAllWallets ();
143
+ #ifdef ENABLE_WALLET
132
144
if (pwalletMain)
133
145
delete pwalletMain;
146
+ #endif
134
147
LogPrintf (" Shutdown : done\n " );
135
148
}
136
149
@@ -479,7 +492,9 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
479
492
fPrintToConsole = GetBoolArg (" -printtoconsole" , false );
480
493
fPrintToDebugger = GetBoolArg (" -printtodebugger" , false );
481
494
fLogTimestamps = GetBoolArg (" -logtimestamps" , true );
495
+ #ifdef ENABLE_WALLET
482
496
bool fDisableWallet = GetBoolArg (" -disablewallet" , false );
497
+ #endif
483
498
484
499
if (mapArgs.count (" -timeout" ))
485
500
{
@@ -525,16 +540,17 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
525
540
InitWarning (_ (" Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction." ));
526
541
}
527
542
543
+ #ifdef ENABLE_WALLET
528
544
strWalletFile = GetArg (" -wallet" , " wallet.dat" );
529
-
545
+ # endif
530
546
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
531
547
532
548
std::string strDataDir = GetDataDir ().string ();
533
-
549
+ # ifdef ENABLE_WALLET
534
550
// Wallet file must be a plain filename without a directory
535
551
if (strWalletFile != boost::filesystem::basename (strWalletFile) + boost::filesystem::extension (strWalletFile))
536
552
return InitError (strprintf (_ (" Wallet %s resides outside data directory %s" ), strWalletFile.c_str (), strDataDir.c_str ()));
537
-
553
+ # endif
538
554
// Make sure only a single Bitcoin process is using the data directory.
539
555
boost::filesystem::path pathLockFile = GetDataDir () / " .lock" ;
540
556
FILE* file = fopen (pathLockFile.string ().c_str (), " a" ); // empty lock file; created if it doesn't exist.
@@ -567,7 +583,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
567
583
int64_t nStart;
568
584
569
585
// ********************************************************* Step 5: verify wallet database integrity
570
-
586
+ # ifdef ENABLE_WALLET
571
587
if (!fDisableWallet ) {
572
588
uiInterface.InitMessage (_ (" Verifying wallet..." ));
573
589
@@ -613,7 +629,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
613
629
return InitError (_ (" wallet.dat corrupt, salvage failed" ));
614
630
}
615
631
} // (!fDisableWallet)
616
-
632
+ # endif // ENABLE_WALLET
617
633
// ********************************************************* Step 6: network initialization
618
634
619
635
RegisterNodeSignals (GetNodeSignals ());
@@ -880,7 +896,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
880
896
}
881
897
882
898
// ********************************************************* Step 8: load wallet
883
-
899
+ # ifdef ENABLE_WALLET
884
900
if (fDisableWallet ) {
885
901
pwalletMain = NULL ;
886
902
LogPrintf (" Wallet disabled!\n " );
@@ -972,7 +988,9 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
972
988
nWalletDBUpdated++;
973
989
}
974
990
} // (!fDisableWallet)
975
-
991
+ #else // ENABLE_WALLET
992
+ LogPrintf (" No wallet compiled in!\n " );
993
+ #endif // !ENABLE_WALLET
976
994
// ********************************************************* Step 9: import blocks
977
995
978
996
// scan for better chains in the block chain database, that are not yet connected in the active best chain
@@ -1016,32 +1034,39 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
1016
1034
// // debug print
1017
1035
LogPrintf (" mapBlockIndex.size() = %" PRIszu" \n " , mapBlockIndex.size ());
1018
1036
LogPrintf (" nBestHeight = %d\n " , chainActive.Height ());
1037
+ #ifdef ENABLE_WALLET
1019
1038
LogPrintf (" setKeyPool.size() = %" PRIszu" \n " , pwalletMain ? pwalletMain->setKeyPool .size () : 0 );
1020
1039
LogPrintf (" mapWallet.size() = %" PRIszu" \n " , pwalletMain ? pwalletMain->mapWallet .size () : 0 );
1021
1040
LogPrintf (" mapAddressBook.size() = %" PRIszu" \n " , pwalletMain ? pwalletMain->mapAddressBook .size () : 0 );
1041
+ #endif
1022
1042
1023
1043
StartNode (threadGroup);
1024
-
1044
+ # ifdef ENABLE_WALLET
1025
1045
// InitRPCMining is needed here so getwork/getblocktemplate in the GUI debug console works properly.
1026
1046
InitRPCMining ();
1047
+ #endif
1027
1048
if (fServer )
1028
1049
StartRPCThreads ();
1029
1050
1051
+ #ifdef ENABLE_WALLET
1030
1052
// Generate coins in the background
1031
1053
if (pwalletMain)
1032
1054
GenerateBitcoins (GetBoolArg (" -gen" , false ), pwalletMain, GetArg (" -genproclimit" , -1 ));
1055
+ #endif
1033
1056
1034
1057
// ********************************************************* Step 12: finished
1035
1058
1036
1059
uiInterface.InitMessage (_ (" Done loading" ));
1037
1060
1061
+ #ifdef ENABLE_WALLET
1038
1062
if (pwalletMain) {
1039
1063
// Add wallet transactions that aren't already in a block to mapTransactions
1040
1064
pwalletMain->ReacceptWalletTransactions ();
1041
1065
1042
1066
// Run a thread to flush wallet periodically
1043
1067
threadGroup.create_thread (boost::bind (&ThreadFlushWalletDB, boost::ref (pwalletMain->strWalletFile )));
1044
1068
}
1069
+ #endif
1045
1070
1046
1071
return !fRequestShutdown ;
1047
1072
}
0 commit comments