Amounts Taker::remaining_offer () const { // If the taker is done, then there's no offer to place. if (done ()) { return Amounts ( Amount (m_amount.in.getCurrency (), m_amount.in.getIssuer ()), Amount (m_amount.out.getCurrency (), m_amount.out.getIssuer ())); } // Avoid math altogether if we didn't cross. if (m_amount == m_remain) return m_amount; if (m_options.sell) { assert (m_remain.in > zero); // We scale the output based on the remaining input: return Amounts (m_remain.in, Amount::divRound ( m_remain.in, m_quality.rate (), m_remain.out, true)); } assert (m_remain.out > zero); // We scale the input based on the remaining output: return Amounts (Amount::mulRound ( m_remain.out, m_quality.rate (), m_remain.in, true), m_remain.out); }
void WalletView::processNewTransaction(const QModelIndex &parent, int start, int /*end*/) { // Prevent balloon-spam when initial block download is in progress if (!walletModel || !clientModel || clientModel->inInitialBlockDownload()) return; TransactionTableModel *ttm = walletModel->getTransactionTableModel(); if (!ttm || ttm->processingQueuedTransactions()) return; QString date = ttm->index(start, TransactionTableModel::Date, parent) .data() .toString(); qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent) .data(Qt::EditRole) .toULongLong(); QString type = ttm->index(start, TransactionTableModel::Type, parent) .data() .toString(); QModelIndex index = ttm->index(start, 0, parent); QString address = ttm->data(index, TransactionTableModel::AddressRole).toString(); QString label = ttm->data(index, TransactionTableModel::LabelRole).toString(); Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), Amount(amount), type, address, label); }
Amount CTxOutCompressor::DecompressAmount(uint64_t x) { // x = 0 OR x = 1+10*(9*n + d - 1) + e OR x = 1+10*(n - 1) + 9 if (x == 0) { return 0; } x--; // x = 10*(9*n + d - 1) + e int e = x % 10; x /= 10; uint64_t n = 0; if (e < 9) { // x = 9*n + d - 1 int d = (x % 9) + 1; x /= 9; // x = n n = x * 10 + d; } else { n = x + 1; } while (e) { n *= 10; e--; } return Amount(int64_t(n)); }
Amount CFeeRate::GetFee(size_t nBytes_) const { assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max())); int64_t nSize = int64_t(nBytes_); Amount nFee = nSize * nSatoshisPerK / 1000; if (nFee == 0 && nSize != 0) { if (nSatoshisPerK > 0) { nFee = Amount(1); } if (nSatoshisPerK < 0) { nFee = Amount(-1); } } return nFee; }
CFeeRate::CFeeRate(const Amount nFeePaid, size_t nBytes_) { assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max())); int64_t nSize = int64_t(nBytes_); if (nSize > 0) { nSatoshisPerK = 1000 * nFeePaid / nSize; } else { nSatoshisPerK = Amount(0); } }
void DealDamageComponent::on_init() { auto body(get_user()->get_component<PhysicsBodyComponent>()); if (body) { body->start_contact.connect([this](PhysicsBodyComponent* self, PhysicsBodyComponent* other, math::vec2 const&) { auto net_object(dynamic_cast<NetworkObject*>(other->get_user())); if (!net_object || net_object->is_local()) { auto life = other->get_user()->get_component<LifeComponent>(); if (life) { life->decrease(Amount(), DamageSourceID(), self->get_linear_velocity()*0.5); } } return true; }); } else { LOG_WARNING << "Failed to initialize DealDamageComponent: No PhysicsBodyComponent found!" << std::endl; } }
Amount Amount::operator-(const Amount amount) { assure_subtractable(value_, amount.value_); return Amount(value_ - amount.value_); }
Amount Amount::operator+(const Amount amount) { assure_addable(value_, amount.value_); return Amount(value_ + amount); }
// methods Amount get_space() const { return Amount(slots) * 100; }
static Amount used_space(Amount num) { return 20 * Amount((num + 19) / 20); }