Exemple #1
0
void database_fixture::set_witness_props( const flat_map< string, vector< char > >& props )
{
   trx.clear();
   for( size_t i=0; i<STEEM_MAX_WITNESSES; i++ )
   {
      witness_set_properties_operation op;
      op.owner = STEEM_INIT_MINER_NAME + (i == 0 ? "" : fc::to_string( i ));
      op.props = props;
      if( props.find( "key" ) == props.end() )
         op.props["key"] = fc::raw::pack_to_vector( init_account_pub_key );

      trx.operations.push_back( op );
      trx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION );
      db->push_transaction( trx, ~0 );
      trx.clear();
   }

   const witness_schedule_object* wso = &(db->get_witness_schedule_object());
   uint32_t old_next_shuffle = wso->next_shuffle_block_num;

   for( size_t i=0; i<2*STEEM_MAX_WITNESSES+1; i++ )
   {
      generate_block();
      wso = &(db->get_witness_schedule_object());
      if( wso->next_shuffle_block_num != old_next_shuffle )
         return;
   }
   FC_ASSERT( false, "Couldn't apply properties in ${n} blocks", ("n", 2*STEEM_MAX_WITNESSES+1) );
}
bool ThriftConfigApplier::updateNeighborResponseTables(
    Vlan* vlan,
    const cfg::Vlan* config) {
    auto origArp = vlan->getArpResponseTable();
    auto origNdp = vlan->getNdpResponseTable();
    ArpResponseTable::Table arpTable;
    NdpResponseTable::Table ndpTable;

    VlanID vlanID(config->id);
    auto it = vlanInterfaces_.find(vlanID);
    if (it != vlanInterfaces_.end()) {
        for (const auto& addrInfo : it->second.addresses) {
            NeighborResponseEntry entry(addrInfo.second.mac,
                                        addrInfo.second.interfaceID);
            if (addrInfo.first.isV4()) {
                arpTable.insert(std::make_pair(addrInfo.first.asV4(), entry));
            } else {
                ndpTable.insert(std::make_pair(addrInfo.first.asV6(), entry));
            }
        }
    }

    bool changed = false;
    if (origArp->getTable() != arpTable) {
        changed = true;
        vlan->setArpResponseTable(origArp->clone(std::move(arpTable)));
    }
    if (origNdp->getTable() != ndpTable) {
        changed = true;
        vlan->setNdpResponseTable(origNdp->clone(std::move(ndpTable)));
    }
    return changed;
}
void account_history_plugin_impl::on_operation( const operation_notification& note )
{
   flat_set<account_name_type> impacted;
   steemit::chain::database& db = database();

   const operation_object* new_obj = nullptr;
   app::operation_get_impacted_accounts( note.op, impacted );

   for( const auto& item : impacted ) {
      auto itr = _tracked_accounts.lower_bound( item );
      if( !_tracked_accounts.size() || (itr != _tracked_accounts.end() && itr->first <= item && item <= itr->second ) ) {
         if( _filter_content )
            note.op.visit( operation_visitor_filter(db, note, new_obj, item) );
         else
            note.op.visit( operation_visitor(db, note, new_obj, item) );
      }
   }
}
BamConfigEntry::Field BamConfigEntry::translate_token(std::string const& tok) {
    // The point of all the original legacy parsing code was to do something
    // close to the original regular expressions in the perl version of
    // breakdancer. For now, we'll just map hits on those original regexes
    // to standard field names that we define. Ultimately, we want to
    // replace this config file format anyway, so there isn't much use
    // in doing something extremely fancy.
    //
    // Defining a config file format is not really the place to allow this level
    // of flexibility. This code should not be carried forward to any new config
    // format that gets developed.
    using boost::regex;
    static flat_map<regex, Field> tok_map = map_list_of
        (regex("map$", regex::icase), BAM_FILE)
        (regex("lib\\w*$", regex::icase), LIBRARY_NAME)
        (regex("group$", regex::icase), READ_GROUP)
        (regex("mean\\w*$", regex::icase), INSERT_SIZE_MEAN)
        (regex("std\\w*$", regex::icase), INSERT_SIZE_STDDEV)
        (regex("readlen\\w*$", regex::icase), READ_LENGTH)
        (regex("upp\\w*$", regex::icase), INSERT_SIZE_UPPER_CUTOFF)
        (regex("low\\w*$", regex::icase), INSERT_SIZE_LOWER_CUTOFF)
        (regex("map\\w*qual\\w*$", regex::icase), MIN_MAP_QUAL)
        (regex("samp\\w*$", regex::icase), SAMPLE_NAME)
        ;

    typedef flat_map<regex, Field>::const_iterator TIter;
    for (TIter iter = tok_map.begin(); iter != tok_map.end(); ++iter) {
        regex const& re = iter->first;
        boost::smatch match;
        // Note: the original perl version didn't force tokens to begin at
        // any particular point, i.e., they could be prefixed. We will
        // retain that behavior for now
        if (boost::regex_search(tok, match, re))
            return iter->second;
    }

    return UNKNOWN;
}
void account_history_plugin_impl::on_operation( const operation_object& op_obj ) {
   flat_set<string> impacted;
   steemit::chain::database& db = database();
   auto size = fc::raw::pack_size(op_obj);
   if( size > 1024*1024*128 ) {
      ilog("excluding transaction from history due to size ${s}", ("s",size) );
      return;
   }

   const auto& hist_idx = db.get_index_type<account_history_index>().indices().get<by_account>();
   const operation_object* new_obj = nullptr;
   app::operation_get_impacted_accounts( op_obj.op, impacted );

   for( const auto& item : impacted ) {
      auto itr = _tracked_accounts.lower_bound( item );
      if( !_tracked_accounts.size() || (itr != _tracked_accounts.end() && itr->first <= item && item <= itr->second ) ) {
         if( _filter_content )
            op_obj.op.visit( operation_visitor_filter(db, op_obj, new_obj, item) );
         else
            op_obj.op.visit( operation_visitor(db, op_obj, new_obj, item) );
      }
   }
}