Exemplo n.º 1
0
void required_approval_index::insert_or_remove_delta( proposal_id_type p,
                                                      const flat_set<account_id_type>& before,
                                                      const flat_set<account_id_type>& after )
{
    auto b = before.begin();
    auto a = after.begin();
    while( b != before.end() || a != after.end() )
    {
       if( a == after.end() || (b != before.end() && *b < *a) )
       {
           remove( *b, p );
           ++b;
       }
       else if( b == before.end() || (a != after.end() && *a < *b) )
       {
           _account_to_proposals[*a].insert( p );
           ++a;
       }
       else // *a == *b
       {
           ++a;
           ++b;
       }
    }
}
Exemplo n.º 2
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.º 3
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.º 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;
    }