mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Use newcoind.cfg instead of config.xml
This commit is contained in:
@@ -126,7 +126,7 @@ Json::Value callRPC(const std::string& strMethod, const Json::Value& params)
|
|||||||
// Connect to localhost
|
// Connect to localhost
|
||||||
|
|
||||||
std::cout << "Connecting to port:" << theConfig.RPC_PORT << std::endl;
|
std::cout << "Connecting to port:" << theConfig.RPC_PORT << std::endl;
|
||||||
ip::tcp::endpoint endpoint( ip::address::from_string("127.0.0.1"), theConfig.RPC_PORT);
|
ip::tcp::endpoint endpoint(ip::address::from_string(theConfig.RPC_IP), theConfig.RPC_PORT);
|
||||||
ip::tcp::iostream stream;
|
ip::tcp::iostream stream;
|
||||||
stream.connect(endpoint);
|
stream.connect(endpoint);
|
||||||
if(stream.fail())
|
if(stream.fail())
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "../util/pugixml.hpp"
|
|
||||||
|
|
||||||
|
#include "ParseSection.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
using namespace pugi;
|
#define CONFIG_FILE_NAME "newcoind.cfg"
|
||||||
|
#define SECTION_PEER_IP "peer_ip"
|
||||||
|
#define SECTION_PEER_PORT "peer_port"
|
||||||
|
#define SECTION_RPC_IP "rpc_ip"
|
||||||
|
#define SECTION_RPC_PORT "rpc_port"
|
||||||
|
#define SECTION_VALIDATION_PASSWORD "validation_password"
|
||||||
|
#define SECTION_VALIDATION_KEY "validation_key"
|
||||||
|
|
||||||
Config theConfig;
|
Config theConfig;
|
||||||
|
|
||||||
@@ -31,16 +39,42 @@ Config::Config()
|
|||||||
|
|
||||||
void Config::load()
|
void Config::load()
|
||||||
{
|
{
|
||||||
|
std::ifstream ifsConfig(CONFIG_FILE_NAME, std::ios::in);
|
||||||
|
|
||||||
xml_document doc;
|
if (!ifsConfig)
|
||||||
xml_parse_result result = doc.load_file("config.xml");
|
{
|
||||||
xml_node root=doc.child("config");
|
std::cerr << "Failed to open '" CONFIG_FILE_NAME "'." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string strConfigFile;
|
||||||
|
|
||||||
xml_node node= root.child("PEER_PORT");
|
strConfigFile.assign((std::istreambuf_iterator<char>(ifsConfig)),
|
||||||
if(!node.empty()) PEER_PORT=boost::lexical_cast<int>(node.child_value());
|
std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
node= root.child("RPC_PORT");
|
if (ifsConfig.bad())
|
||||||
if(!node.empty()) RPC_PORT=boost::lexical_cast<int>(node.child_value());
|
{
|
||||||
|
std::cerr << "Failed to read '" CONFIG_FILE_NAME "'." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
section secConfig = ParseSection(strConfigFile, true);
|
||||||
|
std::string strTemp;
|
||||||
|
|
||||||
|
(void) sectionSingleB(secConfig, SECTION_PEER_IP, PEER_IP);
|
||||||
|
|
||||||
|
if (sectionSingleB(secConfig, SECTION_PEER_PORT, strTemp))
|
||||||
|
PEER_PORT=boost::lexical_cast<int>(strTemp);
|
||||||
|
|
||||||
|
(void) sectionSingleB(secConfig, SECTION_RPC_IP, RPC_IP);
|
||||||
|
|
||||||
|
if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp))
|
||||||
|
RPC_PORT=boost::lexical_cast<int>(strTemp);
|
||||||
|
|
||||||
|
(void) sectionSingleB(secConfig, SECTION_VALIDATION_PASSWORD, VALIDATION_PASSWORD);
|
||||||
|
(void) sectionSingleB(secConfig, SECTION_VALIDATION_KEY, VALIDATION_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
node=root.child("DB_TYPE");
|
node=root.child("DB_TYPE");
|
||||||
@@ -51,3 +85,5 @@ void Config::load()
|
|||||||
}else */
|
}else */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
float BELIEF_PERCENT;
|
float BELIEF_PERCENT;
|
||||||
|
|
||||||
// node networking parameters
|
// node networking parameters
|
||||||
|
std::string PEER_IP;
|
||||||
int PEER_PORT;
|
int PEER_PORT;
|
||||||
int NUMBER_CONNECTIONS;
|
int NUMBER_CONNECTIONS;
|
||||||
bool NODE_INBOUND; // we accept inbound connections
|
bool NODE_INBOUND; // we accept inbound connections
|
||||||
@@ -31,10 +32,14 @@ public:
|
|||||||
std::string HANKO_PRIVATE;
|
std::string HANKO_PRIVATE;
|
||||||
|
|
||||||
// RPC parameters
|
// RPC parameters
|
||||||
|
std::string RPC_IP;
|
||||||
int RPC_PORT;
|
int RPC_PORT;
|
||||||
std::string RPC_USER;
|
std::string RPC_USER;
|
||||||
std::string RPC_PASSWORD;
|
std::string RPC_PASSWORD;
|
||||||
|
|
||||||
|
std::string VALIDATION_PASSWORD;
|
||||||
|
std::string VALIDATION_KEY;
|
||||||
|
|
||||||
// configuration parameters
|
// configuration parameters
|
||||||
std::string DATA_DIR;
|
std::string DATA_DIR;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using namespace std;
|
|||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
PeerDoor::PeerDoor(boost::asio::io_service& io_service) :
|
PeerDoor::PeerDoor(boost::asio::io_service& io_service) :
|
||||||
mAcceptor(io_service, tcp::endpoint(tcp::v4(), theConfig.PEER_PORT))
|
mAcceptor(io_service, tcp::endpoint(address().from_string(theConfig.PEER_IP), theConfig.PEER_PORT))
|
||||||
{
|
{
|
||||||
cout << "Opening peer door on port: " << theConfig.PEER_PORT << endl;
|
cout << "Opening peer door on port: " << theConfig.PEER_PORT << endl;
|
||||||
startListening();
|
startListening();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using namespace std;
|
|||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
RPCDoor::RPCDoor(boost::asio::io_service& io_service) :
|
RPCDoor::RPCDoor(boost::asio::io_service& io_service) :
|
||||||
mAcceptor(io_service, tcp::endpoint(boost::asio::ip::address_v4::loopback(), theConfig.RPC_PORT))
|
mAcceptor(io_service, tcp::endpoint(address::from_string(theConfig.RPC_IP), theConfig.RPC_PORT))
|
||||||
{
|
{
|
||||||
cout << "Opening rpc door on port: " << theConfig.RPC_PORT << endl;
|
cout << "Opening rpc door on port: " << theConfig.RPC_PORT << endl;
|
||||||
startListening();
|
startListening();
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ Json::Value RPCServer::doUnlDefault(Json::Value& params) {
|
|||||||
|
|
||||||
if (!ifsDefault)
|
if (!ifsDefault)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read '" VALIDATORS_FILE_NAME "'." << std::endl;
|
std::cerr << "Failed to open '" VALIDATORS_FILE_NAME "'." << std::endl;
|
||||||
|
|
||||||
bNetwork = true;
|
bNetwork = true;
|
||||||
}
|
}
|
||||||
@@ -566,6 +566,13 @@ Json::Value RPCServer::doUnlDefault(Json::Value& params) {
|
|||||||
{
|
{
|
||||||
strValidators.assign((std::istreambuf_iterator<char>(ifsDefault)),
|
strValidators.assign((std::istreambuf_iterator<char>(ifsDefault)),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
if (ifsDefault.bad())
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to read '" VALIDATORS_FILE_NAME "'." << std::endl;
|
||||||
|
|
||||||
|
bNetwork = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ void UniqueNodeList::responseFetch(const std::string strDomain, const boost::sys
|
|||||||
std::cerr << "Error: " << err.message() << std::endl;
|
std::cerr << "Error: " << err.message() << std::endl;
|
||||||
|
|
||||||
section secSite = ParseSection(strSiteFile, true);
|
section secSite = ParseSection(strSiteFile, true);
|
||||||
section::iterator it;
|
|
||||||
bool bGood = !err;
|
bool bGood = !err;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user