Exemplo n.º 1
0
bool RoseDedupeAuxImpl::hasSafeMultiReports(
    const flat_set<ReportID> &reports) const {
    if (reports.size() <= 1) {
        return true;
    }

    /* We have more than one ReportID corresponding to the external ID that is
     * presented to the user. These may differ in offset adjustment, bounds
     * checks, etc. */

    /* TODO: work out if these differences will actually cause problems */

    /* One common case where we know we don't have a problem is if there are
     * precisely two reports, one for the main Rose path and one for the
     * "small block matcher" path. */
    if (reports.size() == 2) {
        ReportID id1 = *reports.begin();
        ReportID id2 = *reports.rbegin();

        bool has_verts_1 = contains(vert_map, id1);
        bool has_verts_2 = contains(vert_map, id2);
        bool has_sb_verts_1 = contains(sb_vert_map, id1);
        bool has_sb_verts_2 = contains(sb_vert_map, id2);

        if (has_verts_1 != has_verts_2 && has_sb_verts_1 != has_sb_verts_2) {
            DEBUG_PRINTF("two reports, one full and one small block: ok\n");
            return true;
        }
    }

    DEBUG_PRINTF("more than one report\n");
    return false;
}
Exemplo n.º 2
0
void account_history_plugin_impl::update_account_histories( const signed_block& b )
{
   graphene::chain::database& db = database();
   const vector<operation_history_object>& hist = db.get_applied_operations();
   for( auto op : hist )
   {
      // add to the operation history index
      const auto& oho = db.create<operation_history_object>( [&]( operation_history_object& h ){
                                h = op;
                        });

      // get the set of accounts this operation applies to
      flat_set<account_id_type> impacted;
      vector<authority> other;
      operation_get_required_authorities( op.op, impacted, impacted, other );
      op.op.visit( operation_get_impacted_accounts( oho, _self, impacted ) );

      for( auto& a : other )
         for( auto& item : a.account_auths )
            impacted.insert( item.first );

      // for each operation this account applies to that is in the config link it into the history
      if( _tracked_accounts.size() == 0 )
      {
         for( auto& account_id : impacted )
         {
            // we don't do index_account_keys here anymore, because
            // that indexing now happens in observers' post_evaluate()

            // add history
            const auto& stats_obj = account_id(db).statistics(db);
            const auto& ath = db.create<account_transaction_history_object>( [&]( account_transaction_history_object& obj ){
                obj.operation_id = oho.id;
                obj.next = stats_obj.most_recent_op;
            });
            db.modify( stats_obj, [&]( account_statistics_object& obj ){
                obj.most_recent_op = ath.id;
            });
         }
      }
      else
      {
         for( auto account_id : _tracked_accounts )
         {
            if( impacted.find( account_id ) != impacted.end() )
            {
               // add history
               const auto& stats_obj = account_id(db).statistics(db);
               const auto& ath = db.create<account_transaction_history_object>( [&]( account_transaction_history_object& obj ){
                   obj.operation_id = oho.id;
                   obj.next = stats_obj.most_recent_op;
               });
               db.modify( stats_obj, [&]( account_statistics_object& obj ){
                   obj.most_recent_op = ath.id;
               });
            }
         }
      }
   }
}
Exemplo n.º 3
0
 authority_checker( PermissionToAuthorityFunc permission_to_authority, 
                    uint16_t recursion_depth_limit, const flat_set<public_key_type>& signing_keys,
                    flat_set<account_name> provided_auths = flat_set<account_name>() )
    : permission_to_authority(permission_to_authority),
      recursion_depth_limit(recursion_depth_limit),
      signing_keys(signing_keys.begin(), signing_keys.end()),
      _provided_auths(provided_auths.begin(), provided_auths.end()),
      _used_keys(signing_keys.size(), false)
 {}
Exemplo n.º 4
0
    vector<asset> database_api::get_account_balances(account_id_type acnt, const flat_set<asset_id_type>& assets)const
    {
       vector<asset> result;
       if (assets.empty())
       {
          // if the caller passes in an empty list of assets, return balances for all assets the account owns
          const account_balance_index& balance_index = _db.get_index_type<account_balance_index>();
          auto range = balance_index.indices().get<by_account>().equal_range(acnt);
          for (const account_balance_object& balance : boost::make_iterator_range(range.first, range.second))
             result.push_back(asset(balance.get_balance()));
       }
       else
       {
          result.reserve(assets.size());

          std::transform(assets.begin(), assets.end(), std::back_inserter(result),
                         [this, acnt](asset_id_type id) { return _db.get_balance(acnt, id); });
       }

       return result;
    }