rpc: getaddednodeinfo.
This commit is contained in:
parent
f0c9f1ba81
commit
b50f8cc2bb
@ -412,9 +412,38 @@ RPC.prototype.disconnectnode = function disconnectnode(args, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.getaddednodeinfo = function getaddednodeinfo(args, callback) {
|
RPC.prototype.getaddednodeinfo = function getaddednodeinfo(args, callback) {
|
||||||
|
var out = [];
|
||||||
|
var i, peer, peers;
|
||||||
|
|
||||||
if (args.help || args.length < 1 || args.length > 2)
|
if (args.help || args.length < 1 || args.length > 2)
|
||||||
return callback(new RPCError('getaddednodeinfo dummy ( "node" )'));
|
return callback(new RPCError('getaddednodeinfo dummy ( "node" )'));
|
||||||
callback(new Error('Not implemented.'));
|
|
||||||
|
if (args.length === 2) {
|
||||||
|
peer = this.pool.getPeer(String(args[1]));
|
||||||
|
if (!peer)
|
||||||
|
return callback(new RPCError('Node has not been added.'));
|
||||||
|
peers = [peer];
|
||||||
|
} else {
|
||||||
|
peers = this.pool.peers.all;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < peers.length; i++) {
|
||||||
|
peer = peers[i];
|
||||||
|
out.push({
|
||||||
|
addednode: peer.hostname,
|
||||||
|
connected: peer.connected,
|
||||||
|
addresses: [
|
||||||
|
{
|
||||||
|
address: peer.hostname,
|
||||||
|
connected: peer.type !== bcoin.peer.types.LEECH
|
||||||
|
? 'outbound'
|
||||||
|
: 'inbound'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, out);
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.getconnectioncount = function getconnectioncount(args, callback) {
|
RPC.prototype.getconnectioncount = function getconnectioncount(args, callback) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user