aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2015-04-24 21:31:46 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-05-28 09:00:45 +0200
commit3201035f22fe451c808b0bb157d33a58f0d99c07 (patch)
tree88b19ba6bbe283f0648996fd83e385a288da3aa0 /src/init.cpp
parentce56f5621a94dcc2159ebe57e43da727eab18e6c (diff)
[autoprune] allow wallet in pruned mode
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/init.cpp b/src/init.cpp
index f4136f09e9..c102464ad9 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -714,16 +714,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
// if using block pruning, then disable txindex
- // also disable the wallet (for now, until SPV support is implemented in wallet)
if (GetArg("-prune", 0)) {
if (GetBoolArg("-txindex", false))
return InitError(_("Prune mode is incompatible with -txindex."));
#ifdef ENABLE_WALLET
- if (!GetBoolArg("-disablewallet", false)) {
- if (SoftSetBoolArg("-disablewallet", true))
- LogPrintf("%s : parameter interaction: -prune -> setting -disablewallet=1\n", __func__);
- else
- return InitError(_("Can't run with a wallet in prune mode."));
+ if (GetBoolArg("-rescan", false)) {
+ return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
}
#endif
}
@@ -1316,6 +1312,19 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
if (chainActive.Tip() && chainActive.Tip() != pindexRescan)
{
+ //We can't rescan beyond non-pruned blocks, stop and throw an error
+ //this might happen if a user uses a old wallet within a pruned node
+ // or if he ran -disablewallet for a longer time, then decided to re-enable
+ if (fPruneMode)
+ {
+ CBlockIndex *block = chainActive.Tip();
+ while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA) && pindexRescan != block)
+ block = block->pprev;
+
+ if (pindexRescan != block)
+ return InitError(_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)"));
+ }
+
uiInterface.InitMessage(_("Rescanning..."));
LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight);
nStart = GetTimeMillis();