signed_transaction wallet::transfer( const asset& amnt, const bts::address& to ) { try { auto change_address = get_new_address(); std::unordered_set<bts::address> req_sigs; asset total_in; signed_transaction trx; trx.inputs = my->collect_inputs( amnt, total_in, req_sigs ); asset change = total_in - amnt; trx.outputs.push_back( trx_output( claim_by_signature_output( to ), amnt) ); trx.outputs.push_back( trx_output( claim_by_signature_output( change_address ), change) ); trx.sigs.clear(); my->sign_transaction( trx, req_sigs ); uint32_t trx_bytes = fc::raw::pack( trx ).size(); asset fee( my->_current_fee_rate * trx_bytes ); if( amnt.unit == asset::bts ) { if( total_in >= amnt + fee ) { change = change - fee; trx.outputs.back() = trx_output( claim_by_signature_output( change_address ), change ); if( change == asset() ) trx.outputs.pop_back(); // no change required } else { elog( "NOT ENOUGH TO COVER AMOUNT + FEE... GRAB MORE.." ); // TODO: this function should be recursive here, but having 2x the fee should be good enough fee = fee + fee; // double the fee in this case to cover the growth req_sigs.clear(); total_in = asset(); trx.inputs = my->collect_inputs( amnt+fee, total_in, req_sigs ); change = total_in - amnt - fee; trx.outputs.back() = trx_output( claim_by_signature_output( change_address ), change ); if( change == asset() ) trx.outputs.pop_back(); // no change required } } else /// fee is in bts, but we are transferring something else { if( change.amount == fc::uint128_t(0) ) trx.outputs.pop_back(); // no change required // TODO: this function should be recursive here, but having 2x the fee should be good enough, some // transactions may overpay in this case, but this can be optimized later to reduce fees.. for now fee = fee + fee; // double the fee in this case to cover the growth asset total_fee_in; auto extra_in = my->collect_inputs( fee, total_fee_in, req_sigs ); trx.inputs.insert( trx.inputs.end(), extra_in.begin(), extra_in.end() ); trx.outputs.push_back( trx_output( claim_by_signature_output( change_address ), total_fee_in - fee ) ); } trx.sigs.clear(); my->sign_transaction(trx, req_sigs); return trx; } FC_RETHROW_EXCEPTIONS( warn, "${amnt} to ${to}", ("amnt",amnt)("to",to) ) }
main() { for (j = 0; j < 2; j++) { i = foo() + (j ? j + fee() + fie() : k) + fum(); printf("%d ", i); } printf("\n"); }
void oEvent::setupClubInfoData() { if (tClubDataRevision == dataRevision || Clubs.empty()) return; inthashmap fee(Clubs.size()); inthashmap paid(Clubs.size()); inthashmap runners(Clubs.size()); // Individual fees for (oRunnerList::iterator it = Runners.begin(); it != Runners.end(); ++it) { if (it->isRemoved()) continue; oRunner &r = *it; if (r.Club) { int id = r.Club->Id; ++runners[id]; oDataConstInterface di = r.getDCI(); bool skip = r.Class && r.Class->getClassStatus() == oClass::InvalidRefund; if (!skip) { int cardFee = di.getInt("CardFee"); if (cardFee < 0) cardFee = 0; fee[id] += di.getInt("Fee") + cardFee; } paid[id] += di.getInt("Paid"); } } // Team fees for (oTeamList::iterator it = Teams.begin(); it != Teams.end(); ++it) { if (it->isRemoved()) continue; oTeam &t = *it; if (t.Club) { int id = t.Club->Id; oDataConstInterface di = t.getDCI(); bool skip = t.Class && t.Class->getClassStatus() == oClass::InvalidRefund; if (!skip) { fee[id] += di.getInt("Fee"); } paid[id] += di.getInt("Paid"); } } for (oClubList::iterator it = Clubs.begin(); it != Clubs.end(); ++it) { int id = it->Id; it->tFee = fee[id]; it->tPaid = paid[id]; it->tNumRunners = runners[id]; } tClubDataRevision = dataRevision; }
signed_transaction wallet::short_sell( const asset& borrow_amnt, const price& ratio ) { try { auto amnt = borrow_amnt * ratio; FC_ASSERT( borrow_amnt.unit != asset::bts, "You cannot short sell BTS" ); auto change_address = get_new_address(); auto bts_in = amnt; signed_transaction trx; std::unordered_set<bts::address> req_sigs; asset total_in; asset in_with_fee = bts_in; // TODO: add fee proportional to trx size... trx.inputs = my->collect_inputs( in_with_fee, total_in, req_sigs ); asset change = total_in - bts_in; trx.outputs.push_back( trx_output( claim_by_long_output( change_address, ratio ), amnt) ); trx.outputs.push_back( trx_output( claim_by_signature_output( change_address ), change) ); trx.sigs.clear(); my->sign_transaction( trx, req_sigs ); uint32_t trx_bytes = fc::raw::pack( trx ).size(); asset fee( my->_current_fee_rate * trx_bytes ); if( total_in >= amnt + fee ) { change = change - fee; trx.outputs.back() = trx_output( claim_by_signature_output( change_address ), change ); if( change == asset() ) trx.outputs.pop_back(); // no change required } else { elog( "NOT ENOUGH TO COVER AMOUNT + FEE... GRAB MORE.." ); // TODO: this function should be recursive here, but having 2x the fee should be good enough fee = fee + fee; // double the fee in this case to cover the growth req_sigs.clear(); total_in = asset(); trx.inputs = my->collect_inputs( amnt+fee, total_in, req_sigs ); change = total_in - amnt - fee; trx.outputs.back() = trx_output( claim_by_signature_output( change_address ), change ); if( change == asset() ) trx.outputs.pop_back(); // no change required } trx.sigs.clear(); my->sign_transaction(trx, req_sigs); my->_data.open_short_sells[ output_reference( trx.id(), 0 ) ] = trx.outputs[0]; return trx; } FC_RETHROW_EXCEPTIONS( warn, "${amnt} @ ${price}", ("amnt",borrow_amnt)("price",ratio) ) }
~basic_string() { fee (this->get_allocator()); }
static GList *do_fee(std::vector<lti::channel8*> &edges, circles_state_t *ct) { GList *result = NULL; uint64_t start_time_in_ms; uint64_t end_time_in_ms; struct timeval tv; gettimeofday(&tv, NULL); start_time_in_ms = tv.tv_sec * 1000 + tv.tv_usec / 1000; // create FEE functor lti::fastEllipseExtraction::parameters feeParam; feeParam.maxArcGap = 120; feeParam.minLineLen = 3; for (unsigned int i = 0; i < edges.size(); i++) { double pyrScale = pow(2, i); lti::fastEllipseExtraction fee(feeParam); // extract some ellipses fprintf(stderr, "extracting from pyramid %d\n", i); fee.apply(*edges[i]); // build list std::vector<lti::fastEllipseExtraction::ellipseEntry> &ellipses = fee.getEllipseList(); for(unsigned int j=0; j<ellipses.size(); j++) { float a = ellipses[j].a * pyrScale; float b = ellipses[j].b * pyrScale; float r = quadratic_mean_radius(a, b); gboolean in_result = TRUE; // determine if it should go in by radius if (!(ct->minRadius < 0 || r >= ct->minRadius)) { in_result = FALSE; } else if (!(ct->maxRadius < 0 || r <= ct->maxRadius)) { in_result = FALSE; } // compute eccentricity float e = compute_eccentricity(a, b); // if over 0.9, drop completely if (e > 0.9) { continue; } // otherwise, maybe mark if (e > ct->maxEccentricity) { in_result = FALSE; } // all set circle_type *c = g_slice_new(circle_type); c->x = ellipses[j].x * pyrScale; c->y = ellipses[j].y * pyrScale; c->a = ellipses[j].a * pyrScale; c->b = ellipses[j].b * pyrScale; c->t = ellipses[j].t; c->in_result = in_result; result = g_list_prepend(result, c); // print ellipse data fprintf(stderr, " ellipse[%i]: center=(%.0f,%.0f) semiaxis=(%.0f,%.0f) " "angle=%.1f coverage=%.1f%% \n", j, c->x, c->y, c->a, c->b, c->t*180/M_PI, ellipses[j].coverage*100); } } gettimeofday(&tv, NULL); end_time_in_ms = tv.tv_sec * 1000 + tv.tv_usec / 1000; fprintf(stderr, "fee done in %ju ms\n", end_time_in_ms - start_time_in_ms); return result; }