Skip to content

Commit

Permalink
fix address data first fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
goatpig committed Sep 30, 2016
1 parent 2f98e74 commit c3b03cd
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cppForSwig/BlockDataViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ void WalletGroup::updateLedgerFilter(const vector<BinaryData>& walletsList)

////////////////////////////////////////////////////////////////////////////////
void WalletGroup::scanWallets(ScanWalletStruct& scanData,
uint32_t updateID)
int32_t updateID)
{
ReadWriteLock::ReadLock rl(lock_);

Expand Down
4 changes: 2 additions & 2 deletions cppForSwig/BlockDataViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class BlockDataViewer
uint32_t lastScanned_ = 0;
const shared_ptr<ZeroConfContainer> zeroConfCont_;

uint32_t updateID_ = 0;
int32_t updateID_ = 0;
};


Expand Down Expand Up @@ -278,7 +278,7 @@ class WalletGroup
bool pageHistory(bool forcePaging, bool pageAnyway);
void updateLedgerFilter(const vector<BinaryData>& walletsVec);

void scanWallets(ScanWalletStruct&, uint32_t);
void scanWallets(ScanWalletStruct&, int32_t);
void updateGlobalLedgerFirstPage(uint32_t startBlock,
uint32_t endBlock, BDV_refresh forceRefresh);

Expand Down
8 changes: 4 additions & 4 deletions cppForSwig/BtcWallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ uint64_t BtcWallet::getFullBalanceFromDB() const
}

////////////////////////////////////////////////////////////////////////////////
map<BinaryData, uint32_t> BtcWallet::getAddrTxnCounts(uint32_t updateID) const
map<BinaryData, uint32_t> BtcWallet::getAddrTxnCounts(int32_t updateID) const
{
map<BinaryData, uint32_t> countMap;

Expand All @@ -191,7 +191,7 @@ map<BinaryData, uint32_t> BtcWallet::getAddrTxnCounts(uint32_t updateID) const

////////////////////////////////////////////////////////////////////////////////
map<BinaryData, tuple<uint64_t, uint64_t, uint64_t>>
BtcWallet::getAddrBalances(uint32_t updateID) const
BtcWallet::getAddrBalances(int32_t updateID) const
{
//TODO: pass ZC filtering choice from bdmConfig

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
12 changes: 6 additions & 6 deletions cppForSwig/BtcWallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class BtcWallet
uint64_t getUnconfirmedBalance(uint32_t currBlk,
bool includeAllZeroConf=true) const;

map<BinaryData, uint32_t> getAddrTxnCounts(uint32_t updateID) const;
map<BinaryData, uint32_t> getAddrTxnCounts(int32_t updateID) const;
map<BinaryData, tuple<uint64_t, uint64_t, uint64_t>>
getAddrBalances(uint32_t updateID) const;
getAddrBalances(int32_t updateID) const;

uint64_t getWltTotalTxnCount(void) const;

Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -191,8 +191,8 @@ class BtcWallet

set<BinaryData> validZcKeys_;

mutable unsigned lastPulledCountsID_ = 0;
mutable unsigned lastPulledBalancesID_ = 0;
mutable int lastPulledCountsID_ = -1;
mutable int lastPulledBalancesID_ = -1;
};

#endif
Expand Down
6 changes: 6 additions & 0 deletions cppForSwig/DatabaseBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions cppForSwig/ScrAddrObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void ScrAddrObj::updateTxIOMap(map<BinaryData, TxIOPair>& txio_map)

////////////////////////////////////////////////////////////////////////////////
void ScrAddrObj::scanZC(const ScanAddressStruct& scanInfo,
function<bool(const BinaryDataRef)> isZcFromWallet, uint32_t updateID)
function<bool(const BinaryDataRef)> 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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cppForSwig/ScrAddrObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class ScrAddrObj
void updateTxIOMap(map<BinaryData, TxIOPair>& txio_map);

void scanZC(const ScanAddressStruct&, function<bool(const BinaryDataRef)>,
uint32_t);
int32_t);
bool purgeZC(const set<BinaryData>& invalidatedTxOutKeys);

void updateAfterReorg(uint32_t lastValidBlockHeight);
Expand All @@ -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,
Expand Down Expand Up @@ -360,7 +360,7 @@ class ScrAddrObj

map<BinaryData, set<BinaryData> > validZCKeys_;

uint32_t updateID_ = 0;
int32_t updateID_ = 0;
};

#endif

0 comments on commit c3b03cd

Please sign in to comment.