Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
JoelKatz
2013-03-26 11:42:06 -07:00
10 changed files with 72 additions and 59 deletions

View File

@@ -106,7 +106,7 @@ env.Append(LINKFLAGS = ['-rdynamic', '-pthread'])
env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE=1']) env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE=1'])
env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS) env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS)
if (GCC_VERSION[0] > 4 or (GCC_VERSION[0] == 4 and GCC_VERSION[1] >= 7)): if (int(GCC_VERSION[0]) > 4 or (int(GCC_VERSION[0]) == 4 and int(GCC_VERSION[1]) >= 7)):
env.Append(CXXFLAGS = ['-std=c++11']) env.Append(CXXFLAGS = ['-std=c++11'])
if OSX: if OSX:

View File

@@ -17,7 +17,7 @@
# #
# Example: debug.log # Example: debug.log
# #
# [validators]: # [validators]
# List of nodes to always accept as validators. Nodes are specified by domain # List of nodes to always accept as validators. Nodes are specified by domain
# or public key. # or public key.
# #
@@ -32,7 +32,7 @@
# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5 # n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5
# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe # n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe
# #
# [validators_file]: # [validators_file]
# Path to file contain a list of nodes to always accept as validators. Use # Path to file contain a list of nodes to always accept as validators. Use
# this to specify a file other than this file to manage your validators list. # this to specify a file other than this file to manage your validators list.
# #
@@ -51,13 +51,13 @@
# C:/home/johndoe/ripple/validators.txt # C:/home/johndoe/ripple/validators.txt
# /home/johndoe/ripple/validators.txt # /home/johndoe/ripple/validators.txt
# #
# [validators_site]: # [validators_site]
# Specifies where to find validators.txt for UNL boostrapping and RPC # Specifies where to find validators.txt for UNL boostrapping and RPC
# unl_network command. # unl_network command.
# #
# Example: ripple.com # Example: ripple.com
# #
# [ips]: # [ips]
# List of ips where the Ripple protocol is served. For a starter list, you # List of ips where the Ripple protocol is served. For a starter list, you
# can copy entries from: https://ripple.com/ripple.txt # can copy entries from: https://ripple.com/ripple.txt
# #
@@ -80,38 +80,38 @@
# time.nist.gov # time.nist.gov
# pool.ntp.org # pool.ntp.org
# #
# [peer_ip]: # [peer_ip]
# IP address or domain to bind to allow external connections from peers. # IP address or domain to bind to allow external connections from peers.
# Defaults to not binding, which disallows external connections from peers. # Defaults to not binding, which disallows external connections from peers.
# #
# Examples: 0.0.0.0 - Bind on all interfaces. # Examples: 0.0.0.0 - Bind on all interfaces.
# #
# [peer_port]: # [peer_port]
# If peer_ip is supplied, corresponding port to bind to for peer connections. # If peer_ip is supplied, corresponding port to bind to for peer connections.
# #
# [peer_private]: # [peer_private]
# 0 or 1. # 0 or 1.
# 0: request peers to broadcast your address. [default] # 0: request peers to broadcast your address. [default]
# 1: request peers not broadcast your address. # 1: request peers not broadcast your address.
# #
# [rpc_ip]: # [rpc_ip]
# IP address or domain to bind to allow insecure RPC connections. # IP address or domain to bind to allow insecure RPC connections.
# Defaults to not binding, which disallows RPC connections. # Defaults to not binding, which disallows RPC connections.
# #
# [rpc_port]: # [rpc_port]
# If rpc_ip is supplied, corresponding port to bind to for peer connections. # If rpc_ip is supplied, corresponding port to bind to for peer connections.
# #
# [rpc_allow_remote]: # [rpc_allow_remote]
# 0 or 1. # 0 or 1.
# 0: Allow RPC connections only from 127.0.0.1. [default] # 0: Allow RPC connections only from 127.0.0.1. [default]
# 1: Allow RPC connections from any IP. # 1: Allow RPC connections from any IP.
# #
# [rpc_admin_allow]: # [rpc_admin_allow]
# Specify an list of IP addresses allowed to have admin access. One per line. # Specify an list of IP addresses allowed to have admin access. One per line.
# #
# Defaults to 127.0.0.1. # Defaults to 127.0.0.1.
# #
# [rpc_user]: # [rpc_user]
# As a server, require a this user to specified and require rpc_password to # As a server, require a this user to specified and require rpc_password to
# be checked for RPC access via the rpc_ip and rpc_port. The user and password # be checked for RPC access via the rpc_ip and rpc_port. The user and password
# must be specified via HTTP's basic authentication method. # must be specified via HTTP's basic authentication method.
@@ -119,7 +119,7 @@
# As a client, supply this to the server via HTTP's basic authentication # As a client, supply this to the server via HTTP's basic authentication
# method. # method.
# #
# [rpc_password]: # [rpc_password]
# As a server, require a this password to specified and require rpc_user to # As a server, require a this password to specified and require rpc_user to
# be checked for RPC access via the rpc_ip and rpc_port. The user and password # be checked for RPC access via the rpc_ip and rpc_port. The user and password
# must be specified via HTTP's basic authentication method. # must be specified via HTTP's basic authentication method.
@@ -127,7 +127,7 @@
# As a client, supply this to the server via HTTP's basic authentication # As a client, supply this to the server via HTTP's basic authentication
# method. # method.
# #
# [rpc_admin_user]: # [rpc_admin_user]
# As a server, require this as the admin user to be specified. Also, require # As a server, require this as the admin user to be specified. Also, require
# rpc_admin_user and rpc_admin_password to be checked for RPC admin functions. # rpc_admin_user and rpc_admin_password to be checked for RPC admin functions.
# The request must specify these as the admin_user and admin_password in the # The request must specify these as the admin_user and admin_password in the
@@ -135,7 +135,7 @@
# #
# As a client, supply this to the server in the request object. # As a client, supply this to the server in the request object.
# #
# [rpc_admin_password]: # [rpc_admin_password]
# As a server, require this as the admin pasword to be specified. Also, # As a server, require this as the admin pasword to be specified. Also,
# require rpc_admin_user and rpc_admin_password to be checked for RPC admin # require rpc_admin_user and rpc_admin_password to be checked for RPC admin
# functions. The request must specify these as the admin_user and # functions. The request must specify these as the admin_user and
@@ -143,12 +143,12 @@
# #
# As a client, supply this to the server in the request object. # As a client, supply this to the server in the request object.
# #
# [validation_quorum]: # [validation_quorum]
# Sets the minimum number of trusted validations a ledger must have before # Sets the minimum number of trusted validations a ledger must have before
# the server considers it fully validated. Note that if you are validating, # the server considers it fully validated. Note that if you are validating,
# your validation counts. # your validation counts.
# #
# [websocket_public_ip]: # [websocket_public_ip]
# IP address or domain to bind to allow untrusted connections from clients. # IP address or domain to bind to allow untrusted connections from clients.
# In the future, this option will go away and the peer_ip will accept # In the future, this option will go away and the peer_ip will accept
# websocket client connections. # websocket client connections.
@@ -156,7 +156,7 @@
# Examples: 0.0.0.0 - Bind on all interfaces. # Examples: 0.0.0.0 - Bind on all interfaces.
# 127.0.0.1 - Bind on localhost interface. Only local programs may connect. # 127.0.0.1 - Bind on localhost interface. Only local programs may connect.
# #
# [websocket_public_port]: # [websocket_public_port]
# Port to bind to allow untrusted connections from clients. In the future, # Port to bind to allow untrusted connections from clients. In the future,
# this option will go away and the peer_ip will accept websocket client # this option will go away and the peer_ip will accept websocket client
# connections. # connections.
@@ -172,14 +172,14 @@
# reference client currently shares secrets with its server, this should be # reference client currently shares secrets with its server, this should be
# enabled. # enabled.
# #
# [websocket_ip]: # [websocket_ip]
# IP address or domain to bind to allow trusted ADMIN connections from backend # IP address or domain to bind to allow trusted ADMIN connections from backend
# applications. # applications.
# #
# Examples: 0.0.0.0 - Bind on all interfaces. # Examples: 0.0.0.0 - Bind on all interfaces.
# 127.0.0.1 - Bind on localhost interface. Only local programs may connect. # 127.0.0.1 - Bind on localhost interface. Only local programs may connect.
# #
# [websocket_port]: # [websocket_port]
# Port to bind to allow trusted ADMIN connections from backend applications. # Port to bind to allow trusted ADMIN connections from backend applications.
# #
# [websocket_secure] # [websocket_secure]
@@ -188,14 +188,14 @@
# 1: Provide ws and wss service for websocket_ip/websocket_port # 1: Provide ws and wss service for websocket_ip/websocket_port
# 2: Provide wss service for websocket_ip/websocket_port. # 2: Provide wss service for websocket_ip/websocket_port.
# #
# [websocket_ssl_key]: # [websocket_ssl_key]
# Specify the filename holding the SSL key in PEM format. # Specify the filename holding the SSL key in PEM format.
# #
# [websocket_ssl_cert]: # [websocket_ssl_cert]
# Specify the path to the SSL certificate file in PEM format. # Specify the path to the SSL certificate file in PEM format.
# This is not needed if the chain includes it. # This is not needed if the chain includes it.
# #
# [websocket_ssl_chain]: # [websocket_ssl_chain]
# If you need a certificate chain, specify the path to the certificate chain # If you need a certificate chain, specify the path to the certificate chain
# here. The chain may include the end certificate. # here. The chain may include the end certificate.
# #
@@ -205,7 +205,7 @@
# that the server will accept for verifying HTTP servers. Used only for # that the server will accept for verifying HTTP servers. Used only for
# outbound HTTPS client connections. # outbound HTTPS client connections.
# #
# [validation_seed]: # [validation_seed]
# To perform validation, this section should contain either a validation seed # To perform validation, this section should contain either a validation seed
# or key. The validation seed is used to generate the validation # or key. The validation seed is used to generate the validation
# public/private key pair. To obtain a validation seed, use the # public/private key pair. To obtain a validation seed, use the
@@ -214,7 +214,7 @@
# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE # Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE
# shfArahZT9Q9ckTf3s1psJ7C7qzVN # shfArahZT9Q9ckTf3s1psJ7C7qzVN
# #
# [node_seed]: # [node_seed]
# This is used for clustering. To force a particular node seed or key, the # This is used for clustering. To force a particular node seed or key, the
# key can be set here. The format is the same as the validation_seed field. # key can be set here. The format is the same as the validation_seed field.
# To obtain a validation seed, use the validation_create command. # To obtain a validation seed, use the validation_create command.
@@ -222,19 +222,19 @@
# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE # Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE
# shfArahZT9Q9ckTf3s1psJ7C7qzVN # shfArahZT9Q9ckTf3s1psJ7C7qzVN
# #
# [node_size]: # [node_size]
# Tunes the servers based on the expected load and available memory. Legal # Tunes the servers based on the expected load and available memory. Legal
# sizes are "tiny", "small", "medium", "large", and "huge". We recommend # sizes are "tiny", "small", "medium", "large", and "huge". We recommend
# you start at the default and raise the setting if you have extra memory. # you start at the default and raise the setting if you have extra memory.
# The default is "tiny". # The default is "tiny".
# #
# [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'. To give a node a name for identification # 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. # 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
# maintain while running. # maintain while running.
# #
@@ -244,7 +244,7 @@
# #
# The default is: 256 # The default is: 256
# #
# [database_path]: # [database_path]
# Full path of database directory. # Full path of database directory.
# #
# [path_search_size] # [path_search_size]
@@ -253,10 +253,12 @@
# #
# The default is: 5 # The default is: 5
# #
# [rpc_startup]: # [rpc_startup]
# Specify a list of RPC commands to run at startup. # Specify a list of RPC commands to run at startup.
# #
# Example: { "command" : "server_info" } # Examples:
# { "command" : "server_info" }
# { "command" : "log_level", "partition" : "ripplecalc", "severity" : "trace" }
# #
# Allow other peers to connect to this server. # Allow other peers to connect to this server.

View File

@@ -1065,16 +1065,16 @@ void NetworkOPs::setMode(OperatingMode om)
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger) NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin)
{ // can be called with no locks { // can be called with no locks
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > ret; std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > ret;
std::string sql = std::string sql =
str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM " boost::str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID " "AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
"WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' " "WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC LIMIT 200;") "ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC%s;")
% account.humanAccountID() % maxLedger % minLedger); % account.humanAccountID() % maxLedger % minLedger % (bAdmin ? "" : " LIMIT 200"));
{ {
Database* db = theApp->getTxnDB()->getDB(); Database* db = theApp->getTxnDB()->getDB();
@@ -1103,15 +1103,15 @@ std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
} }
std::vector<NetworkOPs::txnMetaLedgerType> NetworkOPs::getAccountTxsB( std::vector<NetworkOPs::txnMetaLedgerType> NetworkOPs::getAccountTxsB(
const RippleAddress& account, uint32 minLedger, uint32 maxLedger) const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin)
{ // can be called with no locks { // can be called with no locks
std::vector< txnMetaLedgerType> ret; std::vector< txnMetaLedgerType> ret;
std::string sql = str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM " std::string sql = str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID " "AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
"WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' " "WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC LIMIT 500;") "ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC%s;")
% account.humanAccountID() % maxLedger % minLedger); % account.humanAccountID() % maxLedger % minLedger % (bAdmin ? "" : " LIMIT 500"));
{ {
Database* db = theApp->getTxnDB()->getDB(); Database* db = theApp->getTxnDB()->getDB();

View File

@@ -294,11 +294,11 @@ public:
// client information retrieval functions // client information retrieval functions
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger); getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin);
typedef boost::tuple<std::string, std::string, uint32> txnMetaLedgerType; typedef boost::tuple<std::string, std::string, uint32> txnMetaLedgerType;
std::vector<txnMetaLedgerType> std::vector<txnMetaLedgerType>
getAccountTxsB(const RippleAddress& account, uint32 minL, uint32 maxL); getAccountTxsB(const RippleAddress& account, uint32 minL, uint32 maxL, bool bAdmin);
std::vector<RippleAddress> getLedgerAffectedAccounts(uint32 ledgerSeq); std::vector<RippleAddress> getLedgerAffectedAccounts(uint32 ledgerSeq);
std::vector<SerializedTransaction> getLedgerTransactions(uint32 ledgerSeq); std::vector<SerializedTransaction> getLedgerTransactions(uint32 ledgerSeq);

View File

@@ -9,7 +9,6 @@
#include "Pathfinder.h" #include "Pathfinder.h"
#include "Log.h" #include "Log.h"
#include "NetworkOPs.h"
#include "RPCHandler.h" #include "RPCHandler.h"
#include "RPCSub.h" #include "RPCSub.h"
#include "Application.h" #include "Application.h"
@@ -1706,7 +1705,8 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest, int& cost)
if (jvRequest.isMember("binary") && jvRequest["binary"].asBool()) if (jvRequest.isMember("binary") && jvRequest["binary"].asBool())
{ {
std::vector<NetworkOPs::txnMetaLedgerType> txns = std::vector<NetworkOPs::txnMetaLedgerType> txns =
mNetOps->getAccountTxsB(raAccount, minLedger, maxLedger); mNetOps->getAccountTxsB(raAccount, minLedger, maxLedger, mRole == ADMIN);
for (std::vector<NetworkOPs::txnMetaLedgerType>::const_iterator it = txns.begin(), end = txns.end(); for (std::vector<NetworkOPs::txnMetaLedgerType>::const_iterator it = txns.begin(), end = txns.end();
it != end; ++it) it != end; ++it)
{ {
@@ -1723,7 +1723,7 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest, int& cost)
} }
else else
{ {
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger); std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger, mRole == ADMIN);
for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it) for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it)
{ {
Json::Value obj(Json::objectValue); Json::Value obj(Json::objectValue);

View File

@@ -8,6 +8,7 @@
#include "RippleAddress.h" #include "RippleAddress.h"
#include "SerializedTypes.h" #include "SerializedTypes.h"
#include "Ledger.h" #include "Ledger.h"
#include "NetworkOPs.h"
#define LEDGER_CURRENT -1 #define LEDGER_CURRENT -1
#define LEDGER_CLOSED -2 #define LEDGER_CLOSED -2

View File

@@ -188,8 +188,17 @@ int main(int argc, char* argv[])
} }
} }
if (iResult)
{
nothing();
}
else if (vm.count("help"))
{
iResult = 1;
}
if (HaveSustain() && if (HaveSustain() &&
!vm.count("parameters") && !vm.count("fg") && !vm.count("standalone") && !vm.count("unittest")) !iResult && !vm.count("parameters") && !vm.count("fg") && !vm.count("standalone") && !vm.count("unittest"))
{ {
std::string logMe = DoSustain(); std::string logMe = DoSustain();
if (!logMe.empty()) if (!logMe.empty())
@@ -251,10 +260,6 @@ int main(int argc, char* argv[])
{ {
nothing(); nothing();
} }
else if (vm.count("help"))
{
iResult = 1;
}
else if (!vm.count("parameters")) else if (!vm.count("parameters"))
{ {
// No arguments. Run server. // No arguments. Run server.

View File

@@ -4,6 +4,10 @@
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/wait.h>
#endif
#include <fstream> #include <fstream>
@@ -443,8 +447,8 @@ std::string DoSustain()
#else #else
bool HaveSustain() { return false; } bool HaveSustain() { return false; }
std::string DoSustain() { return std::string; } std::string DoSustain() { return std::string(); }
std::string StopSustain() { return std::string; } std::string StopSustain() { return std::string(); }
#endif #endif

View File

@@ -192,7 +192,8 @@ Server.prototype.stop = function () {
if (!self.quiet) console.log("server: stop: server exited"); if (!self.quiet) console.log("server: stop: server exited");
self.emit('stopped'); self.emit('stopped');
delete this.child;
delete self.child;
}); });
this.child.kill(); this.child.kill();

View File

@@ -129,14 +129,14 @@ var build_teardown = function (host) {
.connect(false); .connect(false);
}, },
function stopServerStep(callback) { function stopServerStep(callback) {
if (opts.no_server) if (opts.no_server)
{ {
return callback(); return callback();
} }
data.server.on('stopped', callback).stop(); data.server
.on('stopped', callback)
.stop();
} }
], done); ], done);
}; };