MCPcopy Create free account
hub / github.com/cryptonomex/graphene / update

Method update

programs/light_client/Account.cpp:118–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void Account::update(const graphene::chain::account_balance_object& balance)
119{
120 auto balanceItr = std::find_if(m_balances.begin(), m_balances.end(),
121 [&balance](Balance* b) { return b->type()->id() == balance.asset_type.instance.value; });
122
123 if (balanceItr != m_balances.end()) {
124 ilog("Updating ${a}'s balance: ${b}", ("a", name().toStdString())("b", balance));
125 (*balanceItr)->update(balance);
126 Q_EMIT balancesChanged();
127 } else {
128 ilog("Adding to ${a}'s new balance: ${b}", ("a", name().toStdString())("b", balance));
129 Balance* newBalance = new Balance;
130 newBalance->setParent(this);
131 auto model = qobject_cast<ChainDataModel*>(parent());
132 newBalance->setProperty("type", QVariant::fromValue(model->getAsset(balance.asset_type.instance.value)));
133 newBalance->setProperty("amount", QVariant::fromValue(balance.balance.value));
134 m_balances.append(newBalance);
135 Q_EMIT balancesChanged();
136 }
137}

Callers

nothing calls this directly

Calls 5

getAssetMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
idMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected