mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'develop' of github.com:jedmccaleb/NewCoin into develop
This commit is contained in:
@@ -1972,8 +1972,8 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
|
||||
// Only provide, if not fully funded.
|
||||
jvOffer["taker_gets_funded"] = saTakerGetsFunded.getJson(0);
|
||||
jvOffer["taker_pays_funded"] = saTakerPaysFunded.getJson(0);
|
||||
|
||||
}
|
||||
|
||||
STAmount saOwnerPays = QUALITY_ONE == uOfferRate
|
||||
? saTakerGetsFunded
|
||||
: std::min(saOwnerFunds, STAmount::multiply(saTakerGetsFunded, STAmount(CURRENCY_ONE, ACCOUNT_ONE, uOfferRate, -9)));
|
||||
@@ -1985,6 +1985,8 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
|
||||
if (!saOwnerFunds.isZero() || uOfferOwnerID == uTakerID)
|
||||
{
|
||||
// Only provide funded offers and offers of the taker.
|
||||
jvOffer["quality"] = saDirRate.getText();
|
||||
|
||||
jvOffers.append(jvOffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,10 @@ Amount.from_json = function (j) {
|
||||
return (new Amount()).parse_json(j);
|
||||
};
|
||||
|
||||
Amount.from_quality = function (q, c, i) {
|
||||
return (new Amount()).parse_quality(q, c, i);
|
||||
};
|
||||
|
||||
Amount.from_human = function (j) {
|
||||
return (new Amount()).parse_human(j);
|
||||
};
|
||||
@@ -103,6 +107,16 @@ Amount.prototype.add = function (v) {
|
||||
if (!this.is_comparable(v)) {
|
||||
result = Amount.NaN();
|
||||
}
|
||||
else if (v.is_zero()) {
|
||||
result = this;
|
||||
}
|
||||
else if (this.is_zero()) {
|
||||
result = v.clone();
|
||||
result._is_negative = false;
|
||||
result._is_native = this._is_native;
|
||||
result._currency = this._currency;
|
||||
result._issuer = this._issuer;
|
||||
}
|
||||
else if (this._is_native) {
|
||||
result = new Amount();
|
||||
|
||||
@@ -112,13 +126,6 @@ Amount.prototype.add = function (v) {
|
||||
|
||||
result._is_negative = s.compareTo(BigInteger.ZERO) < 0;
|
||||
result._value = result._is_negative ? s.negate() : s;
|
||||
}
|
||||
else if (v.is_zero()) {
|
||||
result = this;
|
||||
}
|
||||
else if (this.is_zero()) {
|
||||
result = v.clone();
|
||||
// YYY Why are these cloned? We never modify them.
|
||||
result._currency = this._currency;
|
||||
result._issuer = this._issuer;
|
||||
}
|
||||
@@ -258,7 +265,8 @@ Amount.prototype.compareTo = function (v) {
|
||||
return result;
|
||||
};
|
||||
|
||||
// Returns copy.
|
||||
// Make d a copy of this. Returns d.
|
||||
// Modification of objects internally refered to is not allowed.
|
||||
Amount.prototype.copyTo = function (d, negate) {
|
||||
if ('object' === typeof this._value)
|
||||
{
|
||||
@@ -275,8 +283,8 @@ Amount.prototype.copyTo = function (d, negate) {
|
||||
? !this._is_negative // Negating.
|
||||
: this._is_negative; // Just copying.
|
||||
|
||||
this._currency.copyTo(d._currency);
|
||||
this._issuer.copyTo(d._issuer);
|
||||
d._currency = this._currency;
|
||||
d._issuer = this._issuer;
|
||||
|
||||
// Prevent negative zero
|
||||
if (d.is_zero()) d._is_negative = false;
|
||||
@@ -606,11 +614,25 @@ Amount.prototype.parse_human = function (j) {
|
||||
};
|
||||
|
||||
Amount.prototype.parse_issuer = function (issuer) {
|
||||
this._issuer.parse_json(issuer);
|
||||
this._issuer = UInt160.from_json(issuer);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// --> h: 8 hex bytes quality or 32 hex bytes directory index.
|
||||
Amount.prototype.parse_quality = function (q, c, i) {
|
||||
this._is_negative = false;
|
||||
this._value = new BigInteger(q.substring(q.length-14), 16);
|
||||
this._offset = parseInt(q.substring(q.length-16, q.length-14), 16)-100;
|
||||
this._currency = Currency.from_json(c);
|
||||
this._issuer = UInt160.from_json(i);
|
||||
this._is_native = this._currency.is_native();
|
||||
|
||||
this.canonicalize();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// <-> j
|
||||
Amount.prototype.parse_json = function (j) {
|
||||
if ('string' === typeof j) {
|
||||
@@ -628,8 +650,8 @@ Amount.prototype.parse_json = function (j) {
|
||||
}
|
||||
else {
|
||||
this.parse_native(j);
|
||||
this._currency = new Currency();
|
||||
this._issuer = new UInt160();
|
||||
this._currency = Currency.from_json("0");
|
||||
this._issuer = UInt160.from_json("0");
|
||||
}
|
||||
}
|
||||
else if ('number' === typeof j) {
|
||||
@@ -757,11 +779,11 @@ Amount.prototype.parse_value = function (j) {
|
||||
|
||||
Amount.prototype.set_currency = function (c) {
|
||||
if ('string' === typeof c) {
|
||||
this._currency.parse_json(c);
|
||||
this._currency = Currency.from_json(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
c.copyTo(this._currency);
|
||||
this._currency = c;
|
||||
}
|
||||
this._is_native = this._currency.is_native();
|
||||
|
||||
@@ -770,9 +792,9 @@ Amount.prototype.set_currency = function (c) {
|
||||
|
||||
Amount.prototype.set_issuer = function (issuer) {
|
||||
if (issuer instanceof UInt160) {
|
||||
issuer.copyTo(this._issuer);
|
||||
this._issuer = issuer;
|
||||
} else {
|
||||
this._issuer.parse_json(issuer);
|
||||
this._issuer = UInt160.from_json(issuer);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -975,7 +997,7 @@ Amount.prototype.not_equals_why = function (d, ignore_issuer) {
|
||||
if (!this._is_native) {
|
||||
if (!this._currency.equals(d._currency)) return "Non-XRP currency differs.";
|
||||
if (!ignore_issuer && !this._issuer.equals(d._issuer)) {
|
||||
return "Non-XRP issuer differs.";
|
||||
return "Non-XRP issuer differs: " + d._issuer.to_json() + "/" + this._issuer.to_json();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1164,11 +1164,11 @@ Remote.prototype.request_ripple_balance = function (account, issuer, currency, c
|
||||
var accountHigh = UInt160.from_json(account).equals(highLimit.issuer());
|
||||
|
||||
request.emit('ripple_state', {
|
||||
'account_balance' : ( accountHigh ? balance.negate() : balance).parse_issuer(account),
|
||||
'peer_balance' : (!accountHigh ? balance.negate() : balance).parse_issuer(issuer),
|
||||
'account_balance' : ( accountHigh ? balance.negate() : balance.clone()).parse_issuer(account),
|
||||
'peer_balance' : (!accountHigh ? balance.negate() : balance.clone()).parse_issuer(issuer),
|
||||
|
||||
'account_limit' : ( accountHigh ? highLimit : lowLimit).parse_issuer(issuer),
|
||||
'peer_limit' : (!accountHigh ? highLimit : lowLimit).parse_issuer(account),
|
||||
'account_limit' : ( accountHigh ? highLimit : lowLimit).clone().parse_issuer(issuer),
|
||||
'peer_limit' : (!accountHigh ? highLimit : lowLimit).clone().parse_issuer(account),
|
||||
|
||||
'account_quality_in' : ( accountHigh ? node.HighQualityIn : node.LowQualityIn),
|
||||
'peer_quality_in' : (!accountHigh ? node.HighQualityIn : node.LowQualityIn),
|
||||
|
||||
Reference in New Issue
Block a user