mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve configuration handling.
- Make VALIDATORS_SITE configurable. - At bootstrap load validators.txt with out a unl_default entry. - Always merge in unl_default at start if available.
This commit is contained in:
@@ -31,6 +31,12 @@
|
||||
# Note: $XDG_CONFIG_HOME defaults to $HOME/.config
|
||||
# $XDG_DATA_HOME defaults to $HOME/.local/share
|
||||
#
|
||||
# [validators_site]:
|
||||
# Specifies where to find validators.txt for UNL boostrapping and RPC command unl_network.
|
||||
# During alpha testing, this defaults to: redstem.com
|
||||
#
|
||||
# Example: newcoin.org
|
||||
#
|
||||
# [unl_default]:
|
||||
# Specifies how to bootstrap the UNL list. The UNL list is based on a
|
||||
# validators.txt file and is maintained in the databases. When newcoind
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#define SECTION_VALIDATION_SEED "validation_seed"
|
||||
#define SECTION_WEBSOCKET_IP "websocket_ip"
|
||||
#define SECTION_WEBSOCKET_PORT "websocket_port"
|
||||
#define SECTION_VALIDATORS_SITE "validators_site"
|
||||
|
||||
// Fees are in XNB.
|
||||
#define DEFAULT_FEE_ACCOUNT_CREATE 1000
|
||||
@@ -143,6 +144,8 @@ void Config::setup(const std::string& strConf)
|
||||
|
||||
ACCOUNT_PROBE_MAX = 10;
|
||||
|
||||
VALIDATORS_SITE = DEFAULT_VALIDATORS_SITE;
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -170,6 +173,8 @@ void Config::load()
|
||||
section secConfig = ParseSection(strConfigFile, true);
|
||||
std::string strTemp;
|
||||
|
||||
(void) sectionSingleB(secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE);
|
||||
|
||||
(void) sectionSingleB(secConfig, SECTION_PEER_IP, PEER_IP);
|
||||
|
||||
if (sectionSingleB(secConfig, SECTION_PEER_PORT, strTemp))
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#define SYSTEM_NAME "newcoin"
|
||||
#define VALIDATORS_SITE "redstem.com"
|
||||
#define SYSTEM_CURRENCY_CODE "XNS"
|
||||
#define SYSTEM_CURRENCY_PRECISION 6
|
||||
|
||||
@@ -18,6 +17,7 @@
|
||||
#define SYSTEM_CURRENCY_PARTS 1000000ull // 10^SYSTEM_CURRENCY_PRECISION
|
||||
#define SYSTEM_CURRENCY_START (SYSTEM_CURRENCY_GIFT*SYSTEM_CURRENCY_USERS*SYSTEM_CURRENCY_PARTS)
|
||||
|
||||
#define DEFAULT_VALIDATORS_SITE "redstem.com"
|
||||
#define VALIDATORS_FILE_NAME "validators.txt"
|
||||
const int SYSTEM_PEER_PORT = 6561;
|
||||
|
||||
@@ -46,6 +46,9 @@ public:
|
||||
boost::filesystem::path DATA_DIR;
|
||||
boost::filesystem::path UNL_DEFAULT;
|
||||
|
||||
// Where to find validators.txt on the Internet.
|
||||
std::string VALIDATORS_SITE;
|
||||
|
||||
// Network parameters
|
||||
int NETWORK_START_TIME; // The Unix time we start ledger 0
|
||||
int TRANSACTION_FEE_BASE;
|
||||
|
||||
@@ -1926,7 +1926,7 @@ Json::Value RPCServer::doUnlList(Json::Value& params)
|
||||
// Populate the UNL from a local validators.txt file.
|
||||
Json::Value RPCServer::doUnlLoad(Json::Value& params)
|
||||
{
|
||||
if (!theApp->getUNL().nodeLoad())
|
||||
if (theConfig.UNL_DEFAULT.empty() || !theApp->getUNL().nodeLoad(theConfig.UNL_DEFAULT))
|
||||
{
|
||||
return RPCError(rpcLOAD_FAILED);
|
||||
}
|
||||
|
||||
@@ -1485,34 +1485,34 @@ Json::Value UniqueNodeList::getUnlJson()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool UniqueNodeList::nodeLoad()
|
||||
bool UniqueNodeList::nodeLoad(boost::filesystem::path pConfig)
|
||||
{
|
||||
if (theConfig.UNL_DEFAULT.empty())
|
||||
if (pConfig.empty())
|
||||
{
|
||||
std::cerr << "UNL_DEFAULT not specified." << std::endl;
|
||||
std::cerr << VALIDATORS_FILE_NAME " path not specified." << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!boost::filesystem::exists(theConfig.UNL_DEFAULT))
|
||||
if (!boost::filesystem::exists(pConfig))
|
||||
{
|
||||
std::cerr << str(boost::format("UNL_DEFAULT not found: %s") % theConfig.UNL_DEFAULT) << std::endl;
|
||||
std::cerr << str(boost::format(VALIDATORS_FILE_NAME " not found: %s") % pConfig) << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!boost::filesystem::is_regular_file(theConfig.UNL_DEFAULT))
|
||||
if (!boost::filesystem::is_regular_file(pConfig))
|
||||
{
|
||||
std::cerr << str(boost::format("UNL_DEFAULT not regular file: %s") % theConfig.UNL_DEFAULT) << std::endl;
|
||||
std::cerr << str(boost::format(VALIDATORS_FILE_NAME " not regular file: %s") % pConfig) << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream ifsDefault(theConfig.UNL_DEFAULT.native().c_str(), std::ios::in);
|
||||
std::ifstream ifsDefault(pConfig.native().c_str(), std::ios::in);
|
||||
|
||||
if (!ifsDefault)
|
||||
{
|
||||
std::cerr << str(boost::format("Failed to open: %s") % theConfig.UNL_DEFAULT) << std::endl;
|
||||
std::cerr << str(boost::format(VALIDATORS_FILE_NAME " failed to open: %s") % pConfig) << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1524,14 +1524,14 @@ bool UniqueNodeList::nodeLoad()
|
||||
|
||||
if (ifsDefault.bad())
|
||||
{
|
||||
std::cerr << str(boost::format("Failed to read: %s") % theConfig.UNL_DEFAULT) << std::endl;
|
||||
std::cerr << str(boost::format("Failed to read: %s") % pConfig) << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
nodeDefault(strValidators, theConfig.UNL_DEFAULT.native());
|
||||
nodeDefault(strValidators, pConfig.native());
|
||||
|
||||
std::cerr << str(boost::format("Processing: %s") % theConfig.UNL_DEFAULT) << std::endl;
|
||||
std::cerr << str(boost::format("Processing: %s") % pConfig) << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1542,7 +1542,7 @@ void UniqueNodeList::validatorsResponse(const boost::system::error_code& err, st
|
||||
|
||||
if (!err)
|
||||
{
|
||||
nodeDefault(strResponse, VALIDATORS_SITE);
|
||||
nodeDefault(strResponse, theConfig.VALIDATORS_SITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1554,7 +1554,7 @@ void UniqueNodeList::nodeNetwork()
|
||||
{
|
||||
HttpsClient::httpsGet(
|
||||
theApp->getIOService(),
|
||||
VALIDATORS_SITE,
|
||||
theConfig.VALIDATORS_SITE,
|
||||
443,
|
||||
VALIDATORS_FILE_PATH,
|
||||
VALIDATORS_FILE_BYTES_MAX,
|
||||
@@ -1581,16 +1581,26 @@ void UniqueNodeList::nodeBootstrap()
|
||||
|
||||
bool bLoaded = iDomains || iNodes;
|
||||
|
||||
if (!bLoaded && !theConfig.UNL_DEFAULT.empty())
|
||||
// Always merge in the file specified in the config.
|
||||
if (!theConfig.UNL_DEFAULT.empty())
|
||||
{
|
||||
std::cerr << "Bootstrapping UNL: loading from file." << std::endl;
|
||||
std::cerr << "Bootstrapping UNL: loading from unl_default." << std::endl;
|
||||
|
||||
bLoaded = nodeLoad();
|
||||
bLoaded = nodeLoad(theConfig.UNL_DEFAULT);
|
||||
}
|
||||
|
||||
// If never loaded anything try the current directory.
|
||||
if (!bLoaded && theConfig.UNL_DEFAULT.empty())
|
||||
{
|
||||
std::cerr << "Bootstrapping UNL: loading from '" VALIDATORS_FILE_NAME "'." << std::endl;
|
||||
|
||||
bLoaded = nodeLoad(VALIDATORS_FILE_NAME);
|
||||
}
|
||||
|
||||
if (!bLoaded)
|
||||
{
|
||||
std::cerr << "Bootstrapping UNL: loading from " VALIDATORS_SITE "." << std::endl;
|
||||
std::cerr << "Bootstrapping UNL: loading from " << theConfig.VALIDATORS_SITE << "." << std::endl;
|
||||
|
||||
nodeNetwork();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
bool nodeInUNL(const NewcoinAddress& naNodePublic);
|
||||
|
||||
void nodeBootstrap();
|
||||
bool nodeLoad();
|
||||
bool nodeLoad(boost::filesystem::path pConfig);
|
||||
void nodeNetwork();
|
||||
|
||||
Json::Value getUnlJson();
|
||||
|
||||
Reference in New Issue
Block a user