mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Add --testnet flag.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Config.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "HashPrefixes.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
@@ -56,10 +57,12 @@
|
||||
#define DEFAULT_FEE_OPERATION 1
|
||||
|
||||
Config theConfig;
|
||||
const char* ALPHABET;
|
||||
|
||||
void Config::setup(const std::string& strConf, bool bQuiet)
|
||||
void Config::setup(const std::string& strConf, bool bTestNet, bool bQuiet)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::string strDbPath, strConfFile;
|
||||
|
||||
//
|
||||
// Determine the config and data directories.
|
||||
@@ -67,21 +70,39 @@ void Config::setup(const std::string& strConf, bool bQuiet)
|
||||
// that with "db" as the data directory.
|
||||
//
|
||||
|
||||
TESTNET = bTestNet;
|
||||
QUIET = bQuiet;
|
||||
|
||||
// TESTNET forces a "test-" prefix on the conf file and db directory.
|
||||
strDbPath = TESTNET ? "test-db" : "db";
|
||||
strConfFile = boost::str(boost::format(TESTNET ? "test-%s" : "%s")
|
||||
% (strConf.empty() ? CONFIG_FILE_NAME : strConf));
|
||||
|
||||
VALIDATORS_BASE = boost::str(boost::format(TESTNET ? "test-%s" : "%s")
|
||||
% VALIDATORS_FILE_NAME);
|
||||
VALIDATORS_URI = boost::str(boost::format("/%s") % VALIDATORS_BASE);
|
||||
|
||||
SIGN_TRANSACTION = TESTNET ? sHP_TestNetTransactionSign : sHP_TransactionSign;
|
||||
SIGN_VALIDATION = TESTNET ? sHP_TestNetValidation : sHP_Validation;
|
||||
SIGN_PROPOSAL = TESTNET ? sHP_TestNetProposal : sHP_Proposal;
|
||||
|
||||
ALPHABET = TESTNET
|
||||
? "RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz"
|
||||
: "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz";
|
||||
|
||||
if (!strConf.empty())
|
||||
{
|
||||
// --conf=<path> : everything is relative that file.
|
||||
CONFIG_FILE = strConf;
|
||||
CONFIG_FILE = strConfFile;
|
||||
CONFIG_DIR = CONFIG_FILE;
|
||||
CONFIG_DIR.remove_filename();
|
||||
DATA_DIR = CONFIG_DIR / "db";
|
||||
DATA_DIR = CONFIG_DIR / strDbPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
CONFIG_DIR = boost::filesystem::current_path();
|
||||
CONFIG_FILE = CONFIG_DIR / CONFIG_FILE_NAME;
|
||||
DATA_DIR = CONFIG_DIR / "db";
|
||||
CONFIG_FILE = CONFIG_DIR / strConfFile;
|
||||
DATA_DIR = CONFIG_DIR / strDbPath;
|
||||
|
||||
if (exists(CONFIG_FILE)
|
||||
// Can we figure out XDG dirs?
|
||||
@@ -111,7 +132,7 @@ void Config::setup(const std::string& strConf, bool bQuiet)
|
||||
}
|
||||
|
||||
CONFIG_DIR = str(boost::format("%s/" SYSTEM_NAME) % strXdgConfigHome);
|
||||
CONFIG_FILE = CONFIG_DIR / CONFIG_FILE_NAME;
|
||||
CONFIG_FILE = CONFIG_DIR / strConfFile;
|
||||
DATA_DIR = str(boost::format("%s/" SYSTEM_NAME) % strXdgDataHome);
|
||||
|
||||
boost::filesystem::create_directories(CONFIG_DIR, ec);
|
||||
@@ -140,6 +161,7 @@ Config::Config()
|
||||
// Defaults
|
||||
//
|
||||
|
||||
TESTNET = false;
|
||||
NETWORK_START_TIME = 1319844908;
|
||||
|
||||
PEER_PORT = SYSTEM_PEER_PORT;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define SYSTEM_CURRENCY_PARTS 1000000ull // 10^SYSTEM_CURRENCY_PRECISION
|
||||
#define SYSTEM_CURRENCY_START (SYSTEM_CURRENCY_GIFT*SYSTEM_CURRENCY_USERS*SYSTEM_CURRENCY_PARTS)
|
||||
|
||||
#define CONFIG_FILE_NAME SYSTEM_NAME "d.cfg" // rippled.cfg
|
||||
#define CONFIG_FILE_NAME SYSTEM_NAME "d.cfg" // rippled.cfg
|
||||
|
||||
#define DEFAULT_VALIDATORS_SITE ""
|
||||
#define VALIDATORS_FILE_NAME "validators.txt"
|
||||
@@ -47,14 +47,17 @@ class Config
|
||||
public:
|
||||
// Configuration parameters
|
||||
bool QUIET;
|
||||
bool TESTNET;
|
||||
|
||||
boost::filesystem::path CONFIG_FILE;
|
||||
boost::filesystem::path CONFIG_DIR;
|
||||
boost::filesystem::path DATA_DIR;
|
||||
boost::filesystem::path DEBUG_LOGFILE;
|
||||
boost::filesystem::path VALIDATORS_FILE;
|
||||
boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg.
|
||||
|
||||
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.
|
||||
std::string VALIDATORS_URI; // URI of validators.txt.
|
||||
std::string VALIDATORS_BASE; // Name with testnet-, if needed.
|
||||
std::vector<std::string> VALIDATORS; // Validators from rippled.cfg.
|
||||
std::vector<std::string> IPS; // Peer IPs from rippled.cfg.
|
||||
std::vector<std::string> SNTP_SERVERS; // SNTP servers from rippled.cfg.
|
||||
@@ -120,12 +123,19 @@ public:
|
||||
// Client behavior
|
||||
int ACCOUNT_PROBE_MAX; // How far to scan for accounts.
|
||||
|
||||
// Signing signatures.
|
||||
uint32 SIGN_TRANSACTION;
|
||||
uint32 SIGN_VALIDATION;
|
||||
uint32 SIGN_PROPOSAL;
|
||||
|
||||
Config();
|
||||
void setup(const std::string& strConf, bool bQuiet);
|
||||
|
||||
void setup(const std::string& strConf, bool bTestNet, bool bQuiet);
|
||||
void load();
|
||||
};
|
||||
|
||||
extern Config theConfig;
|
||||
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
// TXN - Hash of transaction plus signature to give transaction ID
|
||||
const uint32 sHP_TransactionID = 0x54584E00;
|
||||
|
||||
// STX - Hash of inner transaction to sign
|
||||
const uint32 sHP_TransactionSign = 0x53545800;
|
||||
|
||||
// TND - Hash of transaction plus metadata
|
||||
const uint32 sHP_TransactionNode = 0x534E4400;
|
||||
|
||||
@@ -21,12 +18,24 @@ const uint32 sHP_InnerNode = 0x4D494E00;
|
||||
// LGR - Hash of ledger master data for signing
|
||||
const uint32 sHP_Ledger = 0x4C575200;
|
||||
|
||||
// STX - Hash of inner transaction to sign
|
||||
const uint32 sHP_TransactionSign = 0x53545800;
|
||||
|
||||
// VAL - Hash of validation for signing
|
||||
const uint32 sHP_Validation = 0x56414C00;
|
||||
|
||||
// PRP - Hash of proposal for signing
|
||||
const uint32 sHP_Proposal = 0x50525000;
|
||||
|
||||
// stx - TESTNET Hash of inner transaction to sign
|
||||
const uint32 sHP_TestNetTransactionSign = 0x73747800;
|
||||
|
||||
// val - TESTNET Hash of validation for signing
|
||||
const uint32 sHP_TestNetValidation = 0x76616C00;
|
||||
|
||||
// prp - TESTNET Hash of proposal for signing
|
||||
const uint32 sHP_TestNetProposal = 0x70727000;
|
||||
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -120,7 +120,6 @@ int main(int argc, char* argv[])
|
||||
iResult = 2;
|
||||
}
|
||||
|
||||
|
||||
if (iResult)
|
||||
{
|
||||
nothing();
|
||||
@@ -154,6 +153,7 @@ int main(int argc, char* argv[])
|
||||
if (vm.count("unittest"))
|
||||
{
|
||||
unit_test_main(init_unit_test, argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
theConfig.setup(
|
||||
vm.count("conf") ? vm["conf"].as<std::string>() : "", // Config file.
|
||||
!!vm.count("testnet"), // Testnet flag.
|
||||
!!vm.count("quiet")); // Quiet flag.
|
||||
|
||||
if (vm.count("standalone"))
|
||||
|
||||
Reference in New Issue
Block a user