Skip to content

Commit

Permalink
cppwallet ledger entry is built before the BDM reports ready
Browse files Browse the repository at this point in the history
  • Loading branch information
goatpig committed Mar 20, 2014
1 parent 31cd904 commit 18e6135
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions ArmoryQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,7 @@ def loadWalletsAndSettings(self):
LOGINFO(dispStr)
# Register all wallets with TheBDM
TheBDM.registerWallet( wlt.cppWallet )
TheBDM.bdm.registerWallet(wlt.cppWallet)


# Get the last directory
Expand Down
19 changes: 18 additions & 1 deletion cppForSwig/BlockUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2975,6 +2975,7 @@ void BlockDataManager_LevelDB::Reset(void)
registeredOutPoints_.clear();
allScannedUpToBlk_ = 0;


}


Expand Down Expand Up @@ -3678,7 +3679,6 @@ BtcWallet* BlockDataManager_LevelDB::createNewWallet(void)
return newWlt;
}


/////////////////////////////////////////////////////////////////////////////
// This assumes that registeredTxList_ has already been populated from
// the initial blockchain scan. The blockchain contains millions of tx,
Expand All @@ -3689,6 +3689,8 @@ void BlockDataManager_LevelDB::scanRegisteredTxForWallet( BtcWallet & wlt,
{
SCOPED_TIMER("scanRegisteredTxForWallet");

if(wlt.lastScanned_ > blkStart) blkStart = wlt.lastScanned_;

// Make sure RegisteredTx objects have correct data, then sort.
// TODO: Why did I not need this with the MMAP blockchain? Somehow
// I was able to sort correctly without this step, before...?
Expand Down Expand Up @@ -3745,6 +3747,11 @@ void BlockDataManager_LevelDB::scanRegisteredTxForWallet( BtcWallet & wlt,
if(zcEnabled_)
rescanWalletZeroConf(wlt);

uint32_t topBlk = getTopBlockHeight();
if(blkEnd > topBlk)
wlt.lastScanned_ = topBlk;
else if(blkEnd!=0)
wlt.lastScanned_ = blkEnd;
}


Expand Down Expand Up @@ -4510,6 +4517,16 @@ void BlockDataManager_LevelDB::buildAndScanDatabases(
// Since loading takes so long, there's a good chance that new block data
// came in... let's get it.
readBlkFileUpdate();

set<BtcWallet*>::iterator wltIter;
for(wltIter = registeredWallets_.begin();
wltIter != registeredWallets_.end();
wltIter++)
{
BtcWallet* wlt = *wltIter;
scanRegisteredTxForWallet(*wlt, 0, lastTopBlock_);
}

isInitialized_ = true;
purgeZeroConfPool();

Expand Down
5 changes: 4 additions & 1 deletion cppForSwig/BlockUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class ScrAddrObj
class BtcWallet
{
public:
BtcWallet(void) : bdmPtr_(NULL) {}
BtcWallet(void) : bdmPtr_(NULL) {lastScanned_ = 0;}
explicit BtcWallet(BlockDataManager_LevelDB* bdm) : bdmPtr_(bdm) {}
~BtcWallet(void);

Expand Down Expand Up @@ -443,6 +443,8 @@ class BtcWallet

vector<LedgerEntry> & getEmptyLedger(void) { EmptyLedger_.clear(); return EmptyLedger_;}

uint32_t lastScanned_;

private:
vector<ScrAddrObj*> scrAddrPtrs_;
map<BinaryData, ScrAddrObj> scrAddrMap_;
Expand Down Expand Up @@ -621,6 +623,7 @@ class BlockDataManager_LevelDB
static BlockDataManager_LevelDB* theOnlyBDM_;
static bool bdmCreatedYet_;
bool isInitialized_;
uint32_t lastScannedBlock_;


// These will be set for the specific network we are testing
Expand Down

0 comments on commit 18e6135

Please sign in to comment.