mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
JS: Make ledger_hash and friends private in Remote.
This commit is contained in:
@@ -59,10 +59,10 @@ Request.prototype.request_default = function () {
|
|||||||
Request.prototype.ledger_choose = function (current) {
|
Request.prototype.ledger_choose = function (current) {
|
||||||
if (current)
|
if (current)
|
||||||
{
|
{
|
||||||
this.message.ledger_index = this.remote.ledger_current_index;
|
this.message.ledger_index = this.remote._ledger_current_index;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.message.ledger_hash = this.remote.ledger_hash;
|
this.message.ledger_hash = this.remote._ledger_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -162,19 +162,20 @@ Request.prototype.ripple_state = function (account, issuer, currency) {
|
|||||||
|
|
||||||
// --> trusted: truthy, if remote is trusted
|
// --> trusted: truthy, if remote is trusted
|
||||||
var Remote = function (trusted, websocket_ip, websocket_port, trace) {
|
var Remote = function (trusted, websocket_ip, websocket_port, trace) {
|
||||||
this.trusted = trusted;
|
this.trusted = trusted;
|
||||||
this.websocket_ip = websocket_ip;
|
this.websocket_ip = websocket_ip;
|
||||||
this.websocket_port = websocket_port;
|
this.websocket_port = websocket_port;
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.trace = trace;
|
this.trace = trace;
|
||||||
this.ledger_hash = undefined;
|
this._ledger_current_index = undefined;
|
||||||
this.ledger_current_index = undefined;
|
this._ledger_hash = undefined;
|
||||||
this.stand_alone = undefined;
|
this._ledger_time = undefined;
|
||||||
this.online_target = false;
|
this.stand_alone = undefined;
|
||||||
this.online_state = 'closed'; // 'open', 'closed', 'connecting', 'closing'
|
this.online_target = false;
|
||||||
this.state = 'offline'; // 'online', 'offline'
|
this.online_state = 'closed'; // 'open', 'closed', 'connecting', 'closing'
|
||||||
this.retry_timer = undefined;
|
this.state = 'offline'; // 'online', 'offline'
|
||||||
this.retry = undefined;
|
this.retry_timer = undefined;
|
||||||
|
this.retry = undefined;
|
||||||
|
|
||||||
// Cache information for accounts.
|
// Cache information for accounts.
|
||||||
this.accounts = {
|
this.accounts = {
|
||||||
@@ -302,6 +303,10 @@ Remote.prototype.connect = function (online) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Remote.prototype.ledger_hash = function () {
|
||||||
|
return this._ledger_hash;
|
||||||
|
};
|
||||||
|
|
||||||
// Stop from open state.
|
// Stop from open state.
|
||||||
Remote.prototype._connect_stop = function () {
|
Remote.prototype._connect_stop = function () {
|
||||||
delete this.ws.onerror;
|
delete this.ws.onerror;
|
||||||
@@ -452,9 +457,9 @@ Remote.prototype._connect_message = function (ws, json) {
|
|||||||
// XXX Be more defensive fields could be missing or of wrong type.
|
// XXX Be more defensive fields could be missing or of wrong type.
|
||||||
// YYY Might want to do some cache management.
|
// YYY Might want to do some cache management.
|
||||||
|
|
||||||
this.ledger_time = message.ledger_time;
|
this._ledger_time = message.ledger_time;
|
||||||
this.ledger_hash = message.ledger_hash;
|
this._ledger_hash = message.ledger_hash;
|
||||||
this.ledger_current_index = message.ledger_index + 1;
|
this._ledger_current_index = message.ledger_index + 1;
|
||||||
|
|
||||||
this.emit('ledger_closed', message.ledger_hash, message.ledger_index);
|
this.emit('ledger_closed', message.ledger_hash, message.ledger_index);
|
||||||
break;
|
break;
|
||||||
@@ -547,7 +552,7 @@ Remote.prototype.request_ledger_entry = function (type) {
|
|||||||
|
|
||||||
// Transparent caching:
|
// Transparent caching:
|
||||||
request.on('request', function (remote) { // Intercept default request.
|
request.on('request', function (remote) { // Intercept default request.
|
||||||
if (this.ledger_hash) {
|
if (self._ledger_hash) {
|
||||||
// XXX Add caching.
|
// XXX Add caching.
|
||||||
}
|
}
|
||||||
// else if (req.ledger_index)
|
// else if (req.ledger_index)
|
||||||
@@ -690,11 +695,11 @@ Remote.prototype._server_subscribe = function () {
|
|||||||
self.stand_alone = !!message.stand_alone;
|
self.stand_alone = !!message.stand_alone;
|
||||||
|
|
||||||
if (message.ledger_hash && message.ledger_index) {
|
if (message.ledger_hash && message.ledger_index) {
|
||||||
self.ledger_time = message.ledger_time;
|
self._ledger_time = message.ledger_time;
|
||||||
self.ledger_hash = message.ledger_hash;
|
self._ledger_hash = message.ledger_hash;
|
||||||
self.ledger_current_index = message.ledger_index+1;
|
self._ledger_current_index = message.ledger_index+1;
|
||||||
|
|
||||||
self.emit('ledger_closed', self.ledger_hash, self.ledger_current_index-1);
|
self.emit('ledger_closed', self._ledger_hash, self._ledger_current_index-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.emit('subscribed');
|
self.emit('subscribed');
|
||||||
@@ -1030,7 +1035,7 @@ Transaction.prototype.submit = function () {
|
|||||||
if (this.listeners('final').length || this.listeners('lost').length || this.listeners('pending').length) {
|
if (this.listeners('final').length || this.listeners('lost').length || this.listeners('pending').length) {
|
||||||
// There are listeners for 'final', 'lost', or 'pending' arrange to emit them.
|
// There are listeners for 'final', 'lost', or 'pending' arrange to emit them.
|
||||||
|
|
||||||
this.submit_index = this.remote.ledger_current_index;
|
this.submit_index = this.remote._ledger_current_index;
|
||||||
|
|
||||||
var on_ledger_closed = function (ledger_hash, ledger_index) {
|
var on_ledger_closed = function (ledger_hash, ledger_index) {
|
||||||
var stop = false;
|
var stop = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user