mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 10:35:50 +00:00
Improve the 'network_id' configuration option:
The 'network_id' option allows an administrator to specify to which network they intend a server to connect. Servers can leverage this information to optimize routing and prune automatically discovered cross-network connections. This commit will, if merged: - add support for the devnet keyword, which corresponds to network ID #2; - report the network ID, if one is configured, in server_info
This commit is contained in:
@@ -2167,6 +2167,9 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
|
|||||||
if (human)
|
if (human)
|
||||||
info [jss::hostid] = getHostId (admin);
|
info [jss::hostid] = getHostId (admin);
|
||||||
|
|
||||||
|
if (auto const netid = app_.overlay().networkID())
|
||||||
|
info [jss::network_id] = static_cast<Json::UInt>(*netid);
|
||||||
|
|
||||||
info [jss::build_version] = BuildInfo::getVersionString ();
|
info [jss::build_version] = BuildInfo::getVersionString ();
|
||||||
|
|
||||||
info [jss::server_state] = strOperatingMode (admin);
|
info [jss::server_state] = strOperatingMode (admin);
|
||||||
|
|||||||
@@ -253,6 +253,18 @@ public:
|
|||||||
virtual
|
virtual
|
||||||
Json::Value
|
Json::Value
|
||||||
crawlShards(bool pubKey, std::uint32_t hops) = 0;
|
crawlShards(bool pubKey, std::uint32_t hops) = 0;
|
||||||
|
|
||||||
|
/** Returns the ID of the network this server is configured for, if any.
|
||||||
|
|
||||||
|
The ID is just a numerical identifier, with the IDs 0, 1 and 2 used to
|
||||||
|
identify the mainnet, the testnet and the devnet respectively.
|
||||||
|
|
||||||
|
@return The numerical identifier configured by the administrator of the
|
||||||
|
server. An unseated optional, otherwise.
|
||||||
|
*/
|
||||||
|
virtual
|
||||||
|
boost::optional<std::uint32_t>
|
||||||
|
networkID() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ScoreHasLedger
|
struct ScoreHasLedger
|
||||||
|
|||||||
@@ -1328,14 +1328,17 @@ setup_Overlay (BasicConfig const& config)
|
|||||||
if (id == "testnet")
|
if (id == "testnet")
|
||||||
id = "1";
|
id = "1";
|
||||||
|
|
||||||
|
if (id == "devnet")
|
||||||
|
id = "2";
|
||||||
|
|
||||||
setup.networkID = beast::lexicalCastThrow<std::uint32_t>(id);
|
setup.networkID = beast::lexicalCastThrow<std::uint32_t>(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Throw<std::runtime_error>(
|
Throw<std::runtime_error>(
|
||||||
"Configured [network_id] section is invalid: "
|
"Configured [network_id] section is invalid: must be a number "
|
||||||
"must be a number or one of the strings 'main' or 'testnet'");
|
"or one of the strings 'main', 'testnet' or 'devnet'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return setup;
|
return setup;
|
||||||
|
|||||||
@@ -359,10 +359,15 @@ public:
|
|||||||
return peerDisconnectsCharges_;
|
return peerDisconnectsCharges_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::optional<std::uint32_t>
|
||||||
|
networkID() const override
|
||||||
|
{
|
||||||
|
return networkID_;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value
|
Json::Value
|
||||||
crawlShards(bool pubKey, std::uint32_t hops) override;
|
crawlShards(bool pubKey, std::uint32_t hops) override;
|
||||||
|
|
||||||
|
|
||||||
/** Called when the last link from a peer chain is received.
|
/** Called when the last link from a peer chain is received.
|
||||||
|
|
||||||
@param id peer id that received the shard info.
|
@param id peer id that received the shard info.
|
||||||
|
|||||||
@@ -351,6 +351,7 @@ JSS ( missingCommand ); // error
|
|||||||
JSS ( name ); // out: AmendmentTableImpl, PeerImp
|
JSS ( name ); // out: AmendmentTableImpl, PeerImp
|
||||||
JSS ( needed_state_hashes ); // out: InboundLedger
|
JSS ( needed_state_hashes ); // out: InboundLedger
|
||||||
JSS ( needed_transaction_hashes ); // out: InboundLedger
|
JSS ( needed_transaction_hashes ); // out: InboundLedger
|
||||||
|
JSS ( network_id ); // out: NetworkOPs
|
||||||
JSS ( network_ledger ); // out: NetworkOPs
|
JSS ( network_ledger ); // out: NetworkOPs
|
||||||
JSS ( next_refresh_time ); // out: ValidatorSite
|
JSS ( next_refresh_time ); // out: ValidatorSite
|
||||||
JSS ( no_ripple ); // out: AccountLines
|
JSS ( no_ripple ); // out: AccountLines
|
||||||
|
|||||||
Reference in New Issue
Block a user