Esempio n. 1
0
void from_variant( const fc::variant& var, graphene::chain::extension<T>& value, uint32_t max_depth )
{
   value = graphene::chain::extension<T>();
   if( var.is_null() )
      return;
   if( var.is_array() )
   {
      FC_ASSERT( var.size() == 0 );
      return;
   }

   graphene_extension_from_variant_visitor<T> vtor( var.get_object(), value.value, max_depth );
   fc::reflector<T>::visit( vtor );
   FC_ASSERT( vtor.count_left == 0 );    // unrecognized extension throws here
}
Esempio n. 2
0
void ChainDataModel::processUpdatedObject(const fc::variant& update)
{
   if (update.is_null())
      return;
   if (&fc::thread::current() == m_rpc_thread)
   {
      ilog("Proxying object update to app thread.");
      Q_EMIT queueExecute([this,update]{processUpdatedObject(update);});
      return;
   }

   idump((update));
   try {
   auto id = update.as<variant_object>()["id"].as<object_id_type>();
   if (id.space() == protocol_ids) {
      switch (id.type()) {
         default:
            wlog("Update procedure for ${update} is not yet implemented.", ("update", update));
            break;
      }
   } else if (id.space() == implementation_ids) {
      switch (id.type()) {
         case impl_account_balance_object_type: {
            account_balance_object balance = update.as<account_balance_object>();
            auto owner = m_accounts.find(balance.owner.instance.value);
            if (owner != m_accounts.end())
               (*owner)->update(balance);
            else
               elog("Got unexpected balance update:\n${u}\nfor an account I don't have.",
                    ("u", update));
            break;
      }

      default:
         wlog("Update procedure for ${update} is not yet implemented.", ("update", update));
         break;
      }
   } else
      wlog("Update procedure for ${update} is not yet implemented.", ("update", update));
   } catch (const fc::exception& e) {
      elog("Caught exception while updating object: ${e}", ("e", e.to_detail_string()));
   }
}