diff --git a/cppForSwig/BlockDataViewer.cpp b/cppForSwig/BlockDataViewer.cpp index 08b9140cf..fab90fa13 100644 --- a/cppForSwig/BlockDataViewer.cpp +++ b/cppForSwig/BlockDataViewer.cpp @@ -1021,7 +1021,7 @@ void WalletGroup::updateLedgerFilter(const vector& walletsList) //////////////////////////////////////////////////////////////////////////////// void WalletGroup::scanWallets(ScanWalletStruct& scanData, - uint32_t updateID) + int32_t updateID) { ReadWriteLock::ReadLock rl(lock_); diff --git a/cppForSwig/BlockDataViewer.h b/cppForSwig/BlockDataViewer.h index 7b075ffb6..0412e1f97 100644 --- a/cppForSwig/BlockDataViewer.h +++ b/cppForSwig/BlockDataViewer.h @@ -221,7 +221,7 @@ class BlockDataViewer uint32_t lastScanned_ = 0; const shared_ptr zeroConfCont_; - uint32_t updateID_ = 0; + int32_t updateID_ = 0; }; @@ -278,7 +278,7 @@ class WalletGroup bool pageHistory(bool forcePaging, bool pageAnyway); void updateLedgerFilter(const vector& walletsVec); - void scanWallets(ScanWalletStruct&, uint32_t); + void scanWallets(ScanWalletStruct&, int32_t); void updateGlobalLedgerFirstPage(uint32_t startBlock, uint32_t endBlock, BDV_refresh forceRefresh); diff --git a/cppForSwig/BtcWallet.cpp b/cppForSwig/BtcWallet.cpp index dd63e955c..c51847e8b 100644 --- a/cppForSwig/BtcWallet.cpp +++ b/cppForSwig/BtcWallet.cpp @@ -167,7 +167,7 @@ uint64_t BtcWallet::getFullBalanceFromDB() const } //////////////////////////////////////////////////////////////////////////////// -map BtcWallet::getAddrTxnCounts(uint32_t updateID) const +map BtcWallet::getAddrTxnCounts(int32_t updateID) const { map countMap; @@ -191,7 +191,7 @@ map BtcWallet::getAddrTxnCounts(uint32_t updateID) const //////////////////////////////////////////////////////////////////////////////// map> - BtcWallet::getAddrBalances(uint32_t updateID) const + BtcWallet::getAddrBalances(int32_t updateID) const { //TODO: pass ZC filtering choice from bdmConfig @@ -495,7 +495,7 @@ void BtcWallet::updateAfterReorg(uint32_t lastValidBlockHeight) //////////////////////////////////////////////////////////////////////////////// void BtcWallet::scanWalletZeroConf(const ScanWalletStruct& scanInfo, - uint32_t updateID) + int32_t updateID) { /*** Scanning ZC will update the scrAddr ledger with the ZC txio. Ledgers require @@ -529,7 +529,7 @@ void BtcWallet::scanWalletZeroConf(const ScanWalletStruct& scanInfo, } //////////////////////////////////////////////////////////////////////////////// -bool BtcWallet::scanWallet(ScanWalletStruct& scanInfo, uint32_t updateID) +bool BtcWallet::scanWallet(ScanWalletStruct& scanInfo, int32_t updateID) { if (scanInfo.action_ != BDV_ZC) { diff --git a/cppForSwig/BtcWallet.h b/cppForSwig/BtcWallet.h index a08134eb6..98876caba 100644 --- a/cppForSwig/BtcWallet.h +++ b/cppForSwig/BtcWallet.h @@ -87,9 +87,9 @@ class BtcWallet uint64_t getUnconfirmedBalance(uint32_t currBlk, bool includeAllZeroConf=true) const; - map getAddrTxnCounts(uint32_t updateID) const; + map getAddrTxnCounts(int32_t updateID) const; map> - getAddrBalances(uint32_t updateID) const; + getAddrBalances(int32_t updateID) const; uint64_t getWltTotalTxnCount(void) const; @@ -136,11 +136,11 @@ class BtcWallet private: //returns true on bootstrap and new block, false on ZC - bool scanWallet(ScanWalletStruct&, uint32_t); + bool scanWallet(ScanWalletStruct&, int32_t); //wallet side reorg processing void updateAfterReorg(uint32_t lastValidBlockHeight); - void scanWalletZeroConf(const ScanWalletStruct&, uint32_t); + void scanWalletZeroConf(const ScanWalletStruct&, int32_t); void setRegistered(bool isTrue = true) { isRegistered_ = isTrue; } @@ -191,8 +191,8 @@ class BtcWallet set validZcKeys_; - mutable unsigned lastPulledCountsID_ = 0; - mutable unsigned lastPulledBalancesID_ = 0; + mutable int lastPulledCountsID_ = -1; + mutable int lastPulledBalancesID_ = -1; }; #endif diff --git a/cppForSwig/DatabaseBuilder.cpp b/cppForSwig/DatabaseBuilder.cpp index 2e526e1ba..0a0d83f7c 100644 --- a/cppForSwig/DatabaseBuilder.cpp +++ b/cppForSwig/DatabaseBuilder.cpp @@ -221,6 +221,12 @@ Blockchain::ReorganizationState DatabaseBuilder::updateBlocksInDB( topBlockOffset_.offset_ -= rewind; else topBlockOffset_.offset_ = 0; + + if (topBlockOffset_.offset_ == 0) + { + if (topBlockOffset_.fileID_ > 0) + topBlockOffset_.fileID_--; + } } mutex progressMutex; diff --git a/cppForSwig/ScrAddrObj.cpp b/cppForSwig/ScrAddrObj.cpp index 592eb93f8..20e8e5463 100644 --- a/cppForSwig/ScrAddrObj.cpp +++ b/cppForSwig/ScrAddrObj.cpp @@ -117,7 +117,7 @@ void ScrAddrObj::updateTxIOMap(map& txio_map) //////////////////////////////////////////////////////////////////////////////// void ScrAddrObj::scanZC(const ScanAddressStruct& scanInfo, - function isZcFromWallet, uint32_t updateID) + function isZcFromWallet, int32_t updateID) { //Dont use a reference for this loop. We check and set the isFromSelf flag //in this operation, which is based on the wallet this scrAddr belongs to. @@ -326,7 +326,7 @@ uint64_t ScrAddrObj::getTxioCountFromSSH(void) const //////////////////////////////////////////////////////////////////////////////// void ScrAddrObj::fetchDBScrAddrData(uint32_t startBlock, - uint32_t endBlock, uint32_t updateID) + uint32_t endBlock, int32_t updateID) { //maintains first page worth of TxIO in RAM. This call purges ZC, so you //should rescan ZC right after diff --git a/cppForSwig/ScrAddrObj.h b/cppForSwig/ScrAddrObj.h index aa9491629..4e2f95e01 100644 --- a/cppForSwig/ScrAddrObj.h +++ b/cppForSwig/ScrAddrObj.h @@ -254,7 +254,7 @@ class ScrAddrObj void updateTxIOMap(map& txio_map); void scanZC(const ScanAddressStruct&, function, - uint32_t); + int32_t); bool purgeZC(const set& invalidatedTxOutKeys); void updateAfterReorg(uint32_t lastValidBlockHeight); @@ -280,7 +280,7 @@ class ScrAddrObj void fetchDBScrAddrData(uint32_t startBlock, uint32_t endBlock, - uint32_t updateID); + int32_t updateID); void getHistoryForScrAddr( uint32_t startBlock, uint32_t endBlock, @@ -360,7 +360,7 @@ class ScrAddrObj map > validZCKeys_; - uint32_t updateID_ = 0; + int32_t updateID_ = 0; }; #endif