rpc: refactor.
This commit is contained in:
parent
3841eb3e58
commit
0ca46228f5
@ -770,12 +770,12 @@ RPC.prototype.getblock = function getblock(args, callback) {
|
||||
if (!verbose)
|
||||
return callback(null, block.toRaw().toString('hex'));
|
||||
|
||||
return self.blockToJSON(entry, block, false, callback);
|
||||
return self._blockToJSON(entry, block, false, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
RPC.prototype.txToJSON = function txToJSON(tx) {
|
||||
RPC.prototype._txToJSON = function _txToJSON(tx) {
|
||||
var self = this;
|
||||
return {
|
||||
txid: tx.txid,
|
||||
@ -888,11 +888,11 @@ RPC.prototype.getblockheader = function getblockheader(args, callback) {
|
||||
if (!verbose)
|
||||
return callback(null, entry.toRaw().toString('hex', 0, 80));
|
||||
|
||||
return self.blockheaderToJSON(entry, callback);
|
||||
return self._headerToJSON(entry, callback);
|
||||
});
|
||||
};
|
||||
|
||||
RPC.prototype.blockheaderToJSON = function blockheaderToJSON(entry, callback) {
|
||||
RPC.prototype._headerToJSON = function _headerToJSON(entry, callback) {
|
||||
var self = this;
|
||||
entry.getMedianTimeAsync(function(err, medianTime) {
|
||||
if (err)
|
||||
@ -922,7 +922,7 @@ RPC.prototype.blockheaderToJSON = function blockheaderToJSON(entry, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
RPC.prototype.blockToJSON = function blockToJSON(entry, block, txDetails, callback) {
|
||||
RPC.prototype._blockToJSON = function _blockToJSON(entry, block, txDetails, callback) {
|
||||
var self = this;
|
||||
entry.getMedianTimeAsync(function(err, medianTime) {
|
||||
if (err)
|
||||
@ -943,7 +943,7 @@ RPC.prototype.blockToJSON = function blockToJSON(entry, block, txDetails, callba
|
||||
merkleroot: utils.revHex(entry.merkleRoot),
|
||||
tx: block.txs.map(function(tx) {
|
||||
if (txDetails)
|
||||
return self.txToJSON(tx);
|
||||
return self._txToJSON(tx);
|
||||
return tx.rhash;
|
||||
}),
|
||||
time: entry.ts,
|
||||
@ -1120,7 +1120,7 @@ RPC.prototype.getmempoolentry = function getmempoolentry(args, callback) {
|
||||
if (!entry)
|
||||
return callback(new RPCError('Transaction not in mempool.'));
|
||||
|
||||
callback(null, this.entryToJSON(entry));
|
||||
callback(null, this._entryToJSON(entry));
|
||||
};
|
||||
|
||||
RPC.prototype.getrawmempool = function getrawmempool(args, callback) {
|
||||
@ -1151,7 +1151,7 @@ RPC.prototype.mempoolToJSON = function mempoolToJSON(verbose, callback) {
|
||||
if (!entry)
|
||||
continue;
|
||||
|
||||
out[entry.tx.rhash] = this.entryToJSON(entry);
|
||||
out[entry.tx.rhash] = this._entryToJSON(entry);
|
||||
}
|
||||
|
||||
return callback(null, out);
|
||||
@ -1162,7 +1162,7 @@ RPC.prototype.mempoolToJSON = function mempoolToJSON(verbose, callback) {
|
||||
return callback(null, hashes.map(utils.revHex));
|
||||
};
|
||||
|
||||
RPC.prototype.entryToJSON = function entryToJSON(entry) {
|
||||
RPC.prototype._entryToJSON = function _entryToJSON(entry) {
|
||||
var tx = entry.tx;
|
||||
return {
|
||||
size: entry.size,
|
||||
@ -1911,7 +1911,7 @@ RPC.prototype.decoderawtransaction = function decoderawtransaction(args, callbac
|
||||
|
||||
tx = bcoin.tx.fromRaw(toString(args[0]), 'hex');
|
||||
|
||||
callback(null, this.txToJSON(tx));
|
||||
callback(null, this._txToJSON(tx));
|
||||
};
|
||||
|
||||
RPC.prototype.decodescript = function decodescript(args, callback) {
|
||||
@ -1962,7 +1962,7 @@ RPC.prototype.getrawtransaction = function getrawtransaction(args, callback) {
|
||||
if (!verbose)
|
||||
return callback(null, tx.toRaw().toString('hex'));
|
||||
|
||||
json = self.txToJSON(tx);
|
||||
json = self._txToJSON(tx);
|
||||
json.hex = tx.toRaw().toString('hex');
|
||||
|
||||
callback(null, json);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user