mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 17:06:00 +00:00
Assign friendly names to trusted nodes.
This commit is contained in:
@@ -219,7 +219,8 @@
|
|||||||
# [cluster_nodes]:
|
# [cluster_nodes]:
|
||||||
# To extend full trust to other nodes, place their node public keys here.
|
# To extend full trust to other nodes, place their node public keys here.
|
||||||
# Generally, you should only do this for nodes under common administration.
|
# Generally, you should only do this for nodes under common administration.
|
||||||
# Node public keys start with an 'n'.
|
# Node public keys start with an 'n'. To give a node a name for identification
|
||||||
|
# place a space after the public key and then the name.
|
||||||
#
|
#
|
||||||
# [ledger_history]:
|
# [ledger_history]:
|
||||||
# The number of past ledgers to acquire on server startup and the minimum to
|
# The number of past ledgers to acquire on server startup and the minimum to
|
||||||
|
|||||||
@@ -686,7 +686,7 @@ void Peer::recvHello(ripple::TMHello& packet)
|
|||||||
<< "Peer speaks version " <<
|
<< "Peer speaks version " <<
|
||||||
(packet.protoversion() >> 16) << "." << (packet.protoversion() & 0xFF);
|
(packet.protoversion() >> 16) << "." << (packet.protoversion() & 0xFF);
|
||||||
mHello = packet;
|
mHello = packet;
|
||||||
if (theApp->getUNL().nodeInCluster(mNodePublic))
|
if (theApp->getUNL().nodeInCluster(mNodePublic, mNodeName))
|
||||||
{
|
{
|
||||||
mCluster = true;
|
mCluster = true;
|
||||||
mLoad.setPrivileged();
|
mLoad.setPrivileged();
|
||||||
@@ -1785,7 +1785,11 @@ Json::Value Peer::getJson()
|
|||||||
if (mInbound)
|
if (mInbound)
|
||||||
ret["inbound"] = true;
|
ret["inbound"] = true;
|
||||||
if (mCluster)
|
if (mCluster)
|
||||||
|
{
|
||||||
ret["cluster"] = true;
|
ret["cluster"] = true;
|
||||||
|
if (!mNodeName.empty())
|
||||||
|
ret["name"] = mNodeName;
|
||||||
|
}
|
||||||
if (mHello.has_fullversion())
|
if (mHello.has_fullversion())
|
||||||
ret["version"] = mHello.fullversion();
|
ret["version"] = mHello.fullversion();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ private:
|
|||||||
bool mActive;
|
bool mActive;
|
||||||
bool mCluster; // Node in our cluster
|
bool mCluster; // Node in our cluster
|
||||||
RippleAddress mNodePublic; // Node public key of peer.
|
RippleAddress mNodePublic; // Node public key of peer.
|
||||||
|
std::string mNodeName;
|
||||||
ipPort mIpPort;
|
ipPort mIpPort;
|
||||||
ipPort mIpPortConnect;
|
ipPort mIpPortConnect;
|
||||||
uint256 mCookieHash;
|
uint256 mCookieHash;
|
||||||
|
|||||||
@@ -64,15 +64,6 @@ void UniqueNodeList::start()
|
|||||||
// Load information about when we last updated.
|
// Load information about when we last updated.
|
||||||
bool UniqueNodeList::miscLoad()
|
bool UniqueNodeList::miscLoad()
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const std::string& node, theConfig.CLUSTER_NODES)
|
|
||||||
{
|
|
||||||
RippleAddress a = RippleAddress::createNodePublic(node);
|
|
||||||
if (a.isValid())
|
|
||||||
sClusterNodes.insert(a);
|
|
||||||
else
|
|
||||||
cLog(lsWARNING) << "Entry in cluster list invalid: '" << node << "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::recursive_mutex::scoped_lock sl(theApp->getWalletDB()->getDBLock());
|
boost::recursive_mutex::scoped_lock sl(theApp->getWalletDB()->getDBLock());
|
||||||
Database *db=theApp->getWalletDB()->getDB();
|
Database *db=theApp->getWalletDB()->getDB();
|
||||||
|
|
||||||
@@ -105,11 +96,20 @@ bool UniqueNodeList::miscSave()
|
|||||||
|
|
||||||
void UniqueNodeList::trustedLoad()
|
void UniqueNodeList::trustedLoad()
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const std::string& node, theConfig.CLUSTER_NODES)
|
BOOST_FOREACH(const std::string& c, theConfig.CLUSTER_NODES)
|
||||||
{
|
{
|
||||||
|
std::string node, name;
|
||||||
|
size_t s = c.find(' ');
|
||||||
|
if (s != std::string::npos)
|
||||||
|
{
|
||||||
|
name = c.substr(s+1);
|
||||||
|
node = c.substr(0, s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
node = c;
|
||||||
RippleAddress a = RippleAddress::createNodePublic(node);
|
RippleAddress a = RippleAddress::createNodePublic(node);
|
||||||
if (a.isValid())
|
if (a.isValid())
|
||||||
sClusterNodes.insert(a);
|
sClusterNodes.insert(std::make_pair(a, name));
|
||||||
else
|
else
|
||||||
cLog(lsWARNING) << "Entry in cluster list invalid: '" << node << "'";
|
cLog(lsWARNING) << "Entry in cluster list invalid: '" << node << "'";
|
||||||
}
|
}
|
||||||
@@ -1699,7 +1699,17 @@ bool UniqueNodeList::nodeInUNL(const RippleAddress& naNodePublic)
|
|||||||
bool UniqueNodeList::nodeInCluster(const RippleAddress& naNodePublic)
|
bool UniqueNodeList::nodeInCluster(const RippleAddress& naNodePublic)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl(mUNLLock);
|
boost::recursive_mutex::scoped_lock sl(mUNLLock);
|
||||||
return sClusterNodes.count(naNodePublic) != 0;
|
return sClusterNodes.end() != sClusterNodes.find(naNodePublic);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UniqueNodeList::nodeInCluster(const RippleAddress& naNodePublic, std::string& name)
|
||||||
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock sl(mUNLLock);
|
||||||
|
std::map<RippleAddress, std::string>::iterator it = sClusterNodes.find(naNodePublic);
|
||||||
|
if (it == sClusterNodes.end())
|
||||||
|
return false;
|
||||||
|
name = it->second;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ private:
|
|||||||
std::vector<int> viReferrals;
|
std::vector<int> viReferrals;
|
||||||
} scoreNode;
|
} scoreNode;
|
||||||
|
|
||||||
std::set<RippleAddress> sClusterNodes;
|
std::map<RippleAddress, std::string> sClusterNodes;
|
||||||
|
|
||||||
typedef boost::unordered_map<std::string,int> strIndex;
|
typedef boost::unordered_map<std::string,int> strIndex;
|
||||||
typedef std::pair<std::string,int> ipPort;
|
typedef std::pair<std::string,int> ipPort;
|
||||||
@@ -155,6 +155,7 @@ public:
|
|||||||
|
|
||||||
bool nodeInUNL(const RippleAddress& naNodePublic);
|
bool nodeInUNL(const RippleAddress& naNodePublic);
|
||||||
bool nodeInCluster(const RippleAddress& naNodePublic);
|
bool nodeInCluster(const RippleAddress& naNodePublic);
|
||||||
|
bool nodeInCluster(const RippleAddress& naNodePublic, std::string& name);
|
||||||
|
|
||||||
void nodeBootstrap();
|
void nodeBootstrap();
|
||||||
bool nodeLoad(boost::filesystem::path pConfig);
|
bool nodeLoad(boost::filesystem::path pConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user