mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add RPC command peers.
This commit is contained in:
@@ -108,3 +108,16 @@ bool ConnectionPool::connectTo(const std::string& host, const std::string& port)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value ConnectionPool::getPeersJson()
|
||||||
|
{
|
||||||
|
Json::Value ret(Json::arrayValue);
|
||||||
|
|
||||||
|
BOOST_FOREACH(Peer::pointer peer, mPeers)
|
||||||
|
{
|
||||||
|
ret.append(peer->getJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public:
|
|||||||
std::map<uint160, Peer::pointer> getAllConnected();
|
std::map<uint160, Peer::pointer> getAllConnected();
|
||||||
|
|
||||||
bool connectTo(const std::string& host, const std::string& port);
|
bool connectTo(const std::string& host, const std::string& port);
|
||||||
|
|
||||||
|
Json::Value getPeersJson();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -538,6 +538,15 @@ void Peer::punishPeer(PeerPunish)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value Peer::getJson() {
|
||||||
|
Json::Value ret(Json::objectValue);
|
||||||
|
|
||||||
|
ret["ip"] = mSocket.remote_endpoint().address().to_string();
|
||||||
|
ret["hanko"] = mHanko.ToString();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ public:
|
|||||||
|
|
||||||
void punishPeer(PeerPunish pp);
|
void punishPeer(PeerPunish pp);
|
||||||
|
|
||||||
|
Json::Value getJson();
|
||||||
|
|
||||||
//static PackedMessage::pointer createFullLedger(Ledger::pointer ledger);
|
//static PackedMessage::pointer createFullLedger(Ledger::pointer ledger);
|
||||||
static PackedMessage::pointer createLedgerProposal(Ledger::pointer ledger);
|
static PackedMessage::pointer createLedgerProposal(Ledger::pointer ledger);
|
||||||
static PackedMessage::pointer createValidation(Ledger::pointer ledger);
|
static PackedMessage::pointer createValidation(Ledger::pointer ledger);
|
||||||
|
|||||||
@@ -349,6 +349,12 @@ Json::Value RPCServer::doConnect(Json::Value& params)
|
|||||||
return "connecting";
|
return "connecting";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value RPCServer::doPeers(Json::Value& params)
|
||||||
|
{
|
||||||
|
// peers
|
||||||
|
return theApp->getConnectionPool().getPeersJson();
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value RPCServer::doSendTo(Json::Value& params)
|
Json::Value RPCServer::doSendTo(Json::Value& params)
|
||||||
{ // Implement simple sending without gathering
|
{ // Implement simple sending without gathering
|
||||||
// sendto <destination> <amount>
|
// sendto <destination> <amount>
|
||||||
@@ -504,6 +510,7 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
|||||||
if(command=="unlock") return doUnlock(params);
|
if(command=="unlock") return doUnlock(params);
|
||||||
if(command=="sendto") return doSendTo(params);
|
if(command=="sendto") return doSendTo(params);
|
||||||
if(command=="connect") return doConnect(params);
|
if(command=="connect") return doConnect(params);
|
||||||
|
if(command=="peers") return doPeers(params);
|
||||||
if(command=="tx") return doTx(params);
|
if(command=="tx") return doTx(params);
|
||||||
if(command=="ledger") return doLedger(params);
|
if(command=="ledger") return doLedger(params);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class RPCServer : public boost::enable_shared_from_this<RPCServer>
|
|||||||
Json::Value doUnlock(Json::Value& params);
|
Json::Value doUnlock(Json::Value& params);
|
||||||
Json::Value doSendTo(Json::Value& params);
|
Json::Value doSendTo(Json::Value& params);
|
||||||
Json::Value doConnect(Json::Value& params);
|
Json::Value doConnect(Json::Value& params);
|
||||||
|
Json::Value doPeers(Json::Value& params);
|
||||||
Json::Value doTx(Json::Value& params);
|
Json::Value doTx(Json::Value& params);
|
||||||
Json::Value doLedger(Json::Value& params);
|
Json::Value doLedger(Json::Value& params);
|
||||||
Json::Value doAccount(Json::Value& params);
|
Json::Value doAccount(Json::Value& params);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ void printHelp()
|
|||||||
cout << " unlock <passphrase>" << endl;
|
cout << " unlock <passphrase>" << endl;
|
||||||
cout << " familyinfo" << endl;
|
cout << " familyinfo" << endl;
|
||||||
cout << " connect <ip> [<port>]" << endl;
|
cout << " connect <ip> [<port>]" << endl;
|
||||||
|
cout << " peers" << endl;
|
||||||
cout << " sendto <destination> <amount> [<tag>]" << endl;
|
cout << " sendto <destination> <amount> [<tag>]" << endl;
|
||||||
cout << " tx" << endl;
|
cout << " tx" << endl;
|
||||||
cout << " ledger" << endl;
|
cout << " ledger" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user