Parse sweep+consolidation intervals on startup, add consolidationinterval config option, change consolidation interval default to 25, only validate consolidatesaplingaddress if consolidation is enabled
This commit is contained in:
@@ -515,10 +515,11 @@ void CWallet::RunSaplingSweep(int blockHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogPrintf("%s: Sweep enabled at blockHeight=%d nextSweep=%d\n", __func__, blockHeight, nextSweep);
|
||||
if (nextSweep > blockHeight) {
|
||||
LogPrintf("%s: Not time to sweep yet at blockHeight=%d nextSweep=%d\n", __func__, blockHeight, nextSweep);
|
||||
return;
|
||||
}
|
||||
LogPrintf("%s: Sweep enabled at blockHeight=%d nextSweep=%d\n", __func__, blockHeight, nextSweep);
|
||||
|
||||
//Don't Run if consolidation will run soon.
|
||||
if (fSaplingConsolidationEnabled && nextConsolidation - 5 <= blockHeight) {
|
||||
@@ -528,7 +529,7 @@ void CWallet::RunSaplingSweep(int blockHeight) {
|
||||
|
||||
//Don't Run While consolidation is running.
|
||||
if (fConsolidationRunning) {
|
||||
LogPrintf("%s: not sweeping since consolidation is currently running\n", __func__);
|
||||
LogPrintf("%s: not sweeping since consolidation is currently running at height=%d\n", __func__, blockHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -557,29 +558,28 @@ void CWallet::RunSaplingConsolidation(int blockHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogPrintf("%s: consolidation enabled at blockHeight=%d fSweepRunning=%d\n", __func__, blockHeight, fSweepRunning );
|
||||
|
||||
if (fSweepRunning) {
|
||||
if (nextConsolidation > blockHeight) {
|
||||
LogPrintf("%s: Not time to consolidate yet at blockHeight=%d nextConsolidation=%d\n", __func__, blockHeight, nextConsolidation);
|
||||
return;
|
||||
}
|
||||
|
||||
int consolidateInterval = 45;
|
||||
LogPrintf("%s: consolidation enabled at blockHeight=%d fSweepRunning=%d\n", __func__, blockHeight, fSweepRunning );
|
||||
|
||||
if(fZdebug)
|
||||
fprintf(stderr,"%s: height=%d interval=%d\n", __func__, blockHeight, consolidateInterval);
|
||||
|
||||
if (blockHeight % consolidateInterval == 0) {
|
||||
LogPrintf("%s: creating consolidation operation at blockHeight=%d\n", __func__, blockHeight);
|
||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||
std::shared_ptr<AsyncRPCOperation> lastOperation = q->getOperationForId(saplingConsolidationOperationId);
|
||||
if (lastOperation != nullptr) {
|
||||
lastOperation->cancel();
|
||||
}
|
||||
pendingSaplingConsolidationTxs.clear();
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_saplingconsolidation(blockHeight + 5));
|
||||
saplingConsolidationOperationId = operation->getId();
|
||||
q->addOperation(operation);
|
||||
if (fSweepRunning) {
|
||||
LogPrintf("%s: not consolidating since sweep is currently running at height=%d\n", __func__, blockHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
LogPrintf("%s: creating consolidation operation at blockHeight=%d\n", __func__, blockHeight);
|
||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||
std::shared_ptr<AsyncRPCOperation> lastOperation = q->getOperationForId(saplingConsolidationOperationId);
|
||||
if (lastOperation != nullptr) {
|
||||
lastOperation->cancel();
|
||||
}
|
||||
pendingSaplingConsolidationTxs.clear();
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_saplingconsolidation(blockHeight + 5));
|
||||
saplingConsolidationOperationId = operation->getId();
|
||||
q->addOperation(operation);
|
||||
}
|
||||
|
||||
bool CWallet::CommitAutomatedTx(const CTransaction& tx) {
|
||||
|
||||
Reference in New Issue
Block a user