MCPcopy Create free account
hub / github.com/LUX-Core/lux / AddTokenEntry

Method AddTokenEntry

src/wallet.cpp:4410–4452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4408}
4409
4410bool CWallet::AddTokenEntry(const CTokenInfo &token, bool fFlushOnClose) {
4411 LOCK(cs_wallet);
4412
4413 CWalletDB walletdb(strWalletFile, "r+", fFlushOnClose);
4414
4415 uint256 hash = token.GetHash();
4416
4417 bool fInsertedNew = true;
4418
4419 std::map<uint256, CTokenInfo>::iterator it = mapToken.find(hash);
4420 if(it!=mapToken.end()) {
4421 fInsertedNew = false;
4422 }
4423
4424 // Write to disk
4425 CTokenInfo wtoken = token;
4426 if(!fInsertedNew) {
4427 wtoken.nCreateTime = GetAdjustedTime();
4428 } else {
4429 wtoken.nCreateTime = it->second.nCreateTime;
4430 }
4431
4432 if (!walletdb.WriteToken(wtoken))
4433 return false;
4434
4435 mapToken[hash] = wtoken;
4436
4437 NotifyTokenChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
4438
4439 // Refresh token tx
4440 if(fInsertedNew)
4441 {
4442 for(auto it = mapTokenTx.begin(); it != mapTokenTx.end(); it++)
4443 {
4444 uint256 tokenTxHash = it->second.GetHash();
4445 NotifyTokenTransactionChanged(this, tokenTxHash, CT_UPDATED);
4446 }
4447 }
4448
4449 LogPrintf("AddTokenEntry %s\n", wtoken.GetHash().ToString());
4450
4451 return true;
4452}
4453
4454bool CWallet::AddTokenTxEntry(const CTokenTx &tokenTx, bool fFlushOnClose) {
4455 LOCK(cs_wallet);

Callers 2

addTokenEntryMethod · 0.80
updateTokenTxMethod · 0.80

Calls 9

GetAdjustedTimeFunction · 0.85
NotifyTokenChangedFunction · 0.85
WriteTokenMethod · 0.80
GetHashMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected