Sync ledger with wallet.

This commit is contained in:
JoelKatz
2012-01-17 19:19:00 -08:00
parent c35ca834a7
commit b62139cdcc
3 changed files with 12 additions and 0 deletions

View File

@@ -270,6 +270,11 @@ Ledger::pointer Ledger::closeLedger(uint64 timeStamp)
return Ledger::pointer(new Ledger(*this, timeStamp)); return Ledger::pointer(new Ledger(*this, timeStamp));
} }
void LocalAccount::syncLedger(const uint160& acctID)
{
setLedgerBalance(theApp->getMasterLedger().getBalance(acctID));
}
bool Ledger::unitTest() bool Ledger::unitTest()
{ {
uint160 la1=theApp->getWallet().addFamily(CKey::PassPhraseToKey("This is my payphrase!"), false); uint160 la1=theApp->getWallet().addFamily(CKey::PassPhraseToKey("This is my payphrase!"), false);

View File

@@ -122,6 +122,7 @@ public:
uint64 getBalance() const; uint64 getBalance() const;
void setLedgerBalance(uint64_t ledgerBalance); void setLedgerBalance(uint64_t ledgerBalance);
void incAcctSeq(uint32 transAcctSeq); void incAcctSeq(uint32 transAcctSeq);
void syncLedger(const uint160& acctID);
CKey::pointer getPublicKey(); CKey::pointer getPublicKey();
CKey::pointer getPrivateKey(); CKey::pointer getPrivateKey();

View File

@@ -538,6 +538,9 @@ LocalAccount::pointer Wallet::getNewLocalAccount(const uint160& family)
LocalAccount::pointer lac(new LocalAccount(fit->second, seq)); LocalAccount::pointer lac(new LocalAccount(fit->second, seq));
mAccounts.insert(std::make_pair(acct, lac)); mAccounts.insert(std::make_pair(acct, lac));
sl.unlock();
lac->syncLedger(acct);
return lac; return lac;
} }
@@ -553,6 +556,9 @@ LocalAccount::pointer Wallet::getLocalAccount(const uint160& family, int seq)
LocalAccount::pointer lac(new LocalAccount(fit->second, seq)); LocalAccount::pointer lac(new LocalAccount(fit->second, seq));
mAccounts.insert(std::make_pair(acct, lac)); mAccounts.insert(std::make_pair(acct, lac));
sl.unlock();
lac->syncLedger(acct);
return lac; return lac;
} }