| 115 | } |
| 116 | |
| 117 | void ChainDataModel::processUpdatedObject(const fc::variant& update) |
| 118 | { |
| 119 | if (update.is_null()) |
| 120 | return; |
| 121 | if (&fc::thread::current() == m_rpc_thread) |
| 122 | { |
| 123 | ilog("Proxying object update to app thread."); |
| 124 | Q_EMIT queueExecute([this,update]{processUpdatedObject(update);}); |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | idump((update)); |
| 129 | try { |
| 130 | auto id = update.as<variant_object>()["id"].as<object_id_type>(); |
| 131 | if (id.space() == protocol_ids) { |
| 132 | switch (id.type()) { |
| 133 | default: |
| 134 | wlog("Update procedure for ${update} is not yet implemented.", ("update", update)); |
| 135 | break; |
| 136 | } |
| 137 | } else if (id.space() == implementation_ids) { |
| 138 | switch (id.type()) { |
| 139 | case impl_account_balance_object_type: { |
| 140 | account_balance_object balance = update.as<account_balance_object>(); |
| 141 | auto owner = m_accounts.find(balance.owner.instance.value); |
| 142 | if (owner != m_accounts.end()) |
| 143 | (*owner)->update(balance); |
| 144 | else |
| 145 | elog("Got unexpected balance update:\n${u}\nfor an account I don't have.", |
| 146 | ("u", update)); |
| 147 | break; |
| 148 | } |
| 149 | |
| 150 | default: |
| 151 | wlog("Update procedure for ${update} is not yet implemented.", ("update", update)); |
| 152 | break; |
| 153 | } |
| 154 | } else |
| 155 | wlog("Update procedure for ${update} is not yet implemented.", ("update", update)); |
| 156 | } catch (const fc::exception& e) { |
| 157 | elog("Caught exception while updating object: ${e}", ("e", e.to_detail_string())); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | void ChainDataModel::getAssetImpl(QString assetIdentifier, Asset* const * assetInContainer) |
| 162 | { |