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

This commit is contained in:
JoelKatz
2012-11-20 15:21:02 -08:00
14 changed files with 63 additions and 34 deletions

1
.gitignore vendored
View File

@@ -15,6 +15,7 @@
# Ignore object files. # Ignore object files.
*.o *.o
build build
tags
# Ignore locally installed node_modules # Ignore locally installed node_modules
node_modules node_modules

View File

@@ -132,7 +132,7 @@ for file in RIPPLE_SRCS:
rippled = env.Program('build/rippled', RIPPLE_OBJS) rippled = env.Program('build/rippled', RIPPLE_OBJS)
tags = env.CTags('build/obj/tags', RIPPLE_SRCS) tags = env.CTags('tags', RIPPLE_SRCS)
Default(rippled, tags) Default(rippled, tags)

View File

@@ -1,6 +1,8 @@
# #
# Sample rippled.cfg # Sample rippled.cfg
# #
# This file contains configuration information for rippled.
#
# This file should be named rippled.cfg. This file is UTF-8 with Dos, UNIX, # This file should be named rippled.cfg. This file is UTF-8 with Dos, UNIX,
# or Mac style end of lines. Blank lines and lines beginning with '#' are # or Mac style end of lines. Blank lines and lines beginning with '#' are
# ignored. Undefined sections are reserved. No escapes are currently defined. # ignored. Undefined sections are reserved. No escapes are currently defined.
@@ -19,8 +21,7 @@
# #
# Example: ripple.com # Example: ripple.com
# #
# [unl_default]: # [validators_file]:
# XXX This should be called: [validators_file]
# Specifies how to bootstrap the UNL list. The UNL list is based on a # Specifies how to bootstrap the UNL list. The UNL list is based on a
# validators.txt file and is maintained in the databases. When rippled # validators.txt file and is maintained in the databases. When rippled
# starts up, if the databases are missing or are obsolete due to an upgrade # starts up, if the databases are missing or are obsolete due to an upgrade
@@ -75,6 +76,11 @@
# [peer_port]: # [peer_port]:
# Port to bind to allow external connections from peers. # Port to bind to allow external connections from peers.
# #
# [peer_private]:
# 0 or 1.
# 0: allow peers to broadcast your address. [default]
# 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 allow RPC connections. # Defaults to not allow RPC connections.
@@ -83,7 +89,8 @@
# Port to bind to if allowing insecure RPC connections. # Port to bind to if allowing insecure RPC connections.
# #
# [rpc_allow_remote]: # [rpc_allow_remote]:
# 0 or 1. 0 only allows RPC connections from 127.0.0.1. [default 0] # 0 or 1.
# 0: only allows RPC connections from 127.0.0.1. [default]
# #
# [websocket_ip]: # [websocket_ip]:
# IP address or domain to bind to allow client connections. # IP address or domain to bind to allow client connections.

View File

@@ -20,6 +20,7 @@
#define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water" #define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water"
#define SECTION_PEER_IP "peer_ip" #define SECTION_PEER_IP "peer_ip"
#define SECTION_PEER_PORT "peer_port" #define SECTION_PEER_PORT "peer_port"
#define SECTION_PEER_PRIVATE "peer_private"
#define SECTION_PEER_SCAN_INTERVAL_MIN "peer_scan_interval_min" #define SECTION_PEER_SCAN_INTERVAL_MIN "peer_scan_interval_min"
#define SECTION_PEER_SSL_CIPHER_LIST "peer_ssl_cipher_list" #define SECTION_PEER_SSL_CIPHER_LIST "peer_ssl_cipher_list"
#define SECTION_PEER_START_MAX "peer_start_max" #define SECTION_PEER_START_MAX "peer_start_max"
@@ -27,7 +28,7 @@
#define SECTION_RPC_IP "rpc_ip" #define SECTION_RPC_IP "rpc_ip"
#define SECTION_RPC_PORT "rpc_port" #define SECTION_RPC_PORT "rpc_port"
#define SECTION_SNTP "sntp_servers" #define SECTION_SNTP "sntp_servers"
#define SECTION_UNL_DEFAULT "unl_default" #define SECTION_VALIDATORS_FILE "validators_file"
#define SECTION_VALIDATION_QUORUM "validation_quorum" #define SECTION_VALIDATION_QUORUM "validation_quorum"
#define SECTION_VALIDATION_SEED "validation_seed" #define SECTION_VALIDATION_SEED "validation_seed"
#define SECTION_WEBSOCKET_PUBLIC_IP "websocket_public_ip" #define SECTION_WEBSOCKET_PUBLIC_IP "websocket_public_ip"
@@ -143,6 +144,8 @@ void Config::setup(const std::string& strConf)
PEER_START_MAX = DEFAULT_PEER_START_MAX; PEER_START_MAX = DEFAULT_PEER_START_MAX;
PEER_CONNECT_LOW_WATER = DEFAULT_PEER_CONNECT_LOW_WATER; PEER_CONNECT_LOW_WATER = DEFAULT_PEER_CONNECT_LOW_WATER;
PEER_PRIVATE = false;
TRANSACTION_FEE_BASE = 1000; TRANSACTION_FEE_BASE = 1000;
NETWORK_QUORUM = 0; // Don't need to see other nodes NETWORK_QUORUM = 0; // Don't need to see other nodes
@@ -222,6 +225,9 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_PEER_PORT, strTemp)) if (sectionSingleB(secConfig, SECTION_PEER_PORT, strTemp))
PEER_PORT = boost::lexical_cast<int>(strTemp); PEER_PORT = boost::lexical_cast<int>(strTemp);
if (sectionSingleB(secConfig, SECTION_PEER_PRIVATE, strTemp))
PEER_PRIVATE = boost::lexical_cast<bool>(strTemp);
(void) sectionSingleB(secConfig, SECTION_RPC_IP, RPC_IP); (void) sectionSingleB(secConfig, SECTION_RPC_IP, RPC_IP);
if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp)) if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp))
@@ -292,8 +298,8 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) if (sectionSingleB(secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp))
ACCOUNT_PROBE_MAX = boost::lexical_cast<int>(strTemp); ACCOUNT_PROBE_MAX = boost::lexical_cast<int>(strTemp);
if (sectionSingleB(secConfig, SECTION_UNL_DEFAULT, strTemp)) if (sectionSingleB(secConfig, SECTION_VALIDATORS_FILE, strTemp))
UNL_DEFAULT = strTemp; VALIDATORS_FILE = strTemp;
if (sectionSingleB(secConfig, SECTION_DEBUG_LOGFILE, strTemp)) if (sectionSingleB(secConfig, SECTION_DEBUG_LOGFILE, strTemp))
DEBUG_LOGFILE = strTemp; DEBUG_LOGFILE = strTemp;

View File

@@ -50,7 +50,7 @@ public:
boost::filesystem::path CONFIG_DIR; boost::filesystem::path CONFIG_DIR;
boost::filesystem::path DATA_DIR; boost::filesystem::path DATA_DIR;
boost::filesystem::path DEBUG_LOGFILE; boost::filesystem::path DEBUG_LOGFILE;
boost::filesystem::path UNL_DEFAULT; boost::filesystem::path VALIDATORS_FILE;
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet. std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.
std::vector<std::string> VALIDATORS; // Validators from rippled.cfg. std::vector<std::string> VALIDATORS; // Validators from rippled.cfg.
@@ -66,7 +66,7 @@ public:
int LEDGER_SECONDS; int LEDGER_SECONDS;
int LEDGER_PROPOSAL_DELAY_SECONDS; int LEDGER_PROPOSAL_DELAY_SECONDS;
int LEDGER_AVALANCHE_SECONDS; int LEDGER_AVALANCHE_SECONDS;
bool LEDGER_CREATOR; // should be false unless we are starting a new ledger bool LEDGER_CREATOR; // Should be false unless we are starting a new ledger.
bool RUN_STANDALONE; bool RUN_STANDALONE;
// Note: The following parameters do not relate to the UNL or trust at all // Note: The following parameters do not relate to the UNL or trust at all
@@ -81,6 +81,7 @@ public:
int PEER_SCAN_INTERVAL_MIN; int PEER_SCAN_INTERVAL_MIN;
int PEER_START_MAX; int PEER_START_MAX;
unsigned int PEER_CONNECT_LOW_WATER; unsigned int PEER_CONNECT_LOW_WATER;
bool PEER_PRIVATE; // True to ask peers not to relay current IP.
// Websocket networking parameters // Websocket networking parameters
std::string WEBSOCKET_PUBLIC_IP; // XXX Going away. Merge with the inbound peer connction. std::string WEBSOCKET_PUBLIC_IP; // XXX Going away. Merge with the inbound peer connction.

View File

@@ -300,6 +300,7 @@ void ConnectionPool::connectTo(const std::string& strIp, int iPort)
{ {
if (theConfig.RUN_STANDALONE) if (theConfig.RUN_STANDALONE)
return; return;
{ {
Database* db = theApp->getWalletDB()->getDB(); Database* db = theApp->getWalletDB()->getDB();
ScopedLock sl(theApp->getWalletDB()->getDBLock()); ScopedLock sl(theApp->getWalletDB()->getDBLock());

View File

@@ -430,24 +430,29 @@ void Peer::processReadBuffer()
case ripple::mtCONTACT: case ripple::mtCONTACT:
{ {
ripple::TMContact msg; ripple::TMContact msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE)) if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvContact(msg); recvContact(msg);
else else
cLog(lsWARNING) << "parse error: " << type; cLog(lsWARNING) << "parse error: " << type;
} }
break; break;
case ripple::mtGET_PEERS: case ripple::mtGET_PEERS:
{ {
ripple::TMGetPeers msg; ripple::TMGetPeers msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE)) if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetPeers(msg); recvGetPeers(msg);
else else
cLog(lsWARNING) << "parse error: " << type; cLog(lsWARNING) << "parse error: " << type;
} }
break; break;
case ripple::mtPEERS: case ripple::mtPEERS:
{ {
ripple::TMPeers msg; ripple::TMPeers msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE)) if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvPeers(msg); recvPeers(msg);
else else
@@ -666,7 +671,17 @@ void Peer::recvHello(ripple::TMHello& packet)
std::string strIP = getSocket().remote_endpoint().address().to_string(); std::string strIP = getSocket().remote_endpoint().address().to_string();
int iPort = packet.ipv4port(); int iPort = packet.ipv4port();
theApp->getConnectionPool().savePeer(strIP, iPort, UniqueNodeList::vsInbound); if (mHello.nodeprivate())
{
cLog(lsINFO) << boost::str(boost::format("Recv(Hello): Private connection: %s %s") % strIP % iPort);
}
else
{
// Don't save IP address if the node wants privacy.
// Note: We don't go so far as to delete it. If a node which has previously announced itself now wants
// privacy, it should at least change its port.
theApp->getConnectionPool().savePeer(strIP, iPort, UniqueNodeList::vsInbound);
}
} }
// Consider us connected. No longer accepting mtHELLO. // Consider us connected. No longer accepting mtHELLO.
@@ -994,7 +1009,7 @@ void Peer::recvGetContacts(ripple::TMGetContacts& packet)
{ {
} }
// return a list of your favorite people // Return a list of your favorite people
// TODO: filter out all the LAN peers // TODO: filter out all the LAN peers
// TODO: filter out the peer you are talking to // TODO: filter out the peer you are talking to
void Peer::recvGetPeers(ripple::TMGetPeers& packet) void Peer::recvGetPeers(ripple::TMGetPeers& packet)
@@ -1510,6 +1525,7 @@ void Peer::sendHello()
h.set_nodepublic(theApp->getWallet().getNodePublic().humanNodePublic()); h.set_nodepublic(theApp->getWallet().getNodePublic().humanNodePublic());
h.set_nodeproof(&vchSig[0], vchSig.size()); h.set_nodeproof(&vchSig[0], vchSig.size());
h.set_ipv4port(theConfig.PEER_PORT); h.set_ipv4port(theConfig.PEER_PORT);
h.set_nodeprivate(theConfig.PEER_PRIVATE);
Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger(); Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger();
if (closedLedger && closedLedger->isClosed()) if (closedLedger && closedLedger->isClosed())
@@ -1526,7 +1542,7 @@ void Peer::sendHello()
void Peer::sendGetPeers() void Peer::sendGetPeers()
{ {
// get other peers this guy knows about // Ask peer for known other peers.
ripple::TMGetPeers getPeers; ripple::TMGetPeers getPeers;
getPeers.set_doweneedthis(1); getPeers.set_doweneedthis(1);

View File

@@ -49,6 +49,7 @@ private:
ipPort mIpPortConnect; ipPort mIpPortConnect;
uint256 mCookieHash; uint256 mCookieHash;
uint64 mPeerId; uint64 mPeerId;
bool mPrivate; // Keep peer IP private.
uint256 mClosedLedgerHash, mPreviousLedgerHash; uint256 mClosedLedgerHash, mPreviousLedgerHash;
std::list<uint256> mRecentLedgers; std::list<uint256> mRecentLedgers;

View File

@@ -1640,7 +1640,7 @@ Json::Value RPCHandler::doUnlList(const Json::Value& params)
// Populate the UNL from a local validators.txt file. // Populate the UNL from a local validators.txt file.
Json::Value RPCHandler::doUnlLoad(const Json::Value& params) Json::Value RPCHandler::doUnlLoad(const Json::Value& params)
{ {
if (theConfig.UNL_DEFAULT.empty() || !theApp->getUNL().nodeLoad(theConfig.UNL_DEFAULT)) if (theConfig.VALIDATORS_FILE.empty() || !theApp->getUNL().nodeLoad(theConfig.VALIDATORS_FILE))
{ {
return rpcError(rpcLOAD_FAILED); return rpcError(rpcLOAD_FAILED);
} }

View File

@@ -15,11 +15,11 @@ Transactor::pointer Transactor::makeTransactor(const SerializedTransaction& txn,
{ {
switch(txn.getTxnType()) switch(txn.getTxnType())
{ {
case ttPAYMENT: case ttPAYMENT:
return( Transactor::pointer(new PaymentTransactor(txn,params,engine)) ); return( Transactor::pointer(new PaymentTransactor(txn,params,engine)) );
case ttACCOUNT_SET: case ttACCOUNT_SET:
return( Transactor::pointer(new AccountSetTransactor(txn,params,engine)) ); return( Transactor::pointer(new AccountSetTransactor(txn,params,engine)) );
case ttREGULAR_KEY_SET: case ttREGULAR_KEY_SET:
return( Transactor::pointer(new RegularKeySetTransactor(txn,params,engine)) ); return( Transactor::pointer(new RegularKeySetTransactor(txn,params,engine)) );
case ttTRUST_SET: case ttTRUST_SET:
return( Transactor::pointer(new TrustSetTransactor(txn,params,engine)) ); return( Transactor::pointer(new TrustSetTransactor(txn,params,engine)) );
@@ -35,14 +35,11 @@ Transactor::pointer Transactor::makeTransactor(const SerializedTransaction& txn,
} }
Transactor::Transactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : mTxn(txn), mParams(params), mEngine(engine) Transactor::Transactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : mTxn(txn), mEngine(engine), mParams(params)
{ {
mHasAuthKey=false; mHasAuthKey=false;
} }
void Transactor::calculateFee() void Transactor::calculateFee()
{ {
mFeeDue = theConfig.FEE_DEFAULT; mFeeDue = theConfig.FEE_DEFAULT;
@@ -61,7 +58,7 @@ TER Transactor::payFee()
} }
if( !saPaid ) return tesSUCCESS; if( !saPaid ) return tesSUCCESS;
// Deduct the fee, so it's not available during the transaction. // Deduct the fee, so it's not available during the transaction.
// Will only write the account back, if the transaction succeeds. // Will only write the account back, if the transaction succeeds.
if (mSourceBalance < saPaid) if (mSourceBalance < saPaid)
@@ -73,12 +70,11 @@ TER Transactor::payFee()
return terINSUF_FEE_B; return terINSUF_FEE_B;
} }
mSourceBalance -= saPaid; mSourceBalance -= saPaid;
mTxnAccount->setFieldAmount(sfBalance, mSourceBalance); mTxnAccount->setFieldAmount(sfBalance, mSourceBalance);
return tesSUCCESS;
return tesSUCCESS;
} }
@@ -108,7 +104,7 @@ TER Transactor::checkSig()
return temBAD_AUTH_MASTER; return temBAD_AUTH_MASTER;
} }
return tesSUCCESS; return tesSUCCESS;
} }
@@ -133,11 +129,10 @@ TER Transactor::checkSeq()
if (mEngine->getLedger()->hasTransaction(txID)) if (mEngine->getLedger()->hasTransaction(txID))
return tefALREADY; return tefALREADY;
} }
cLog(lsWARNING) << "applyTransaction: past sequence number"; cLog(lsWARNING) << "applyTransaction: past sequence number";
return tefPAST_SEQ; return tefPAST_SEQ;
}else }else
{ {
mTxnAccount->setFieldU32(sfSequence, t_seq + 1); mTxnAccount->setFieldU32(sfSequence, t_seq + 1);
@@ -209,12 +204,13 @@ TER Transactor::apply()
terResult=checkSig(); terResult=checkSig();
if(terResult != tesSUCCESS) return(terResult); if(terResult != tesSUCCESS) return(terResult);
terResult=checkSeq(); terResult=checkSeq();
if(terResult != tesSUCCESS) return(terResult); if(terResult != tesSUCCESS) return(terResult);
mEngine->entryModify(mTxnAccount); mEngine->entryModify(mTxnAccount);
return doApply(); return doApply();
}
}
// vim:ts=4

View File

@@ -1576,15 +1576,15 @@ void UniqueNodeList::nodeBootstrap()
bool bLoaded = iDomains || iNodes; bool bLoaded = iDomains || iNodes;
// Always merge in the file specified in the config. // Always merge in the file specified in the config.
if (!theConfig.UNL_DEFAULT.empty()) if (!theConfig.VALIDATORS_FILE.empty())
{ {
cLog(lsINFO) << "Bootstrapping UNL: loading from unl_default."; cLog(lsINFO) << "Bootstrapping UNL: loading from unl_default.";
bLoaded = nodeLoad(theConfig.UNL_DEFAULT); bLoaded = nodeLoad(theConfig.VALIDATORS_FILE);
} }
// If never loaded anything try the current directory. // If never loaded anything try the current directory.
if (!bLoaded && theConfig.UNL_DEFAULT.empty()) if (!bLoaded && theConfig.VALIDATORS_FILE.empty())
{ {
cLog(lsINFO) << "Bootstrapping UNL: loading from '" VALIDATORS_FILE_NAME "'."; cLog(lsINFO) << "Bootstrapping UNL: loading from '" VALIDATORS_FILE_NAME "'.";

View File

@@ -34,7 +34,6 @@ enum MessageType {
// Sent on connect // Sent on connect
message TMHello { message TMHello {
required uint32 protoVersion = 1; required uint32 protoVersion = 1;
required uint32 protoVersionMin = 2; required uint32 protoVersionMin = 2;
@@ -46,6 +45,7 @@ message TMHello {
optional uint32 ledgerIndex = 8; optional uint32 ledgerIndex = 8;
optional bytes ledgerClosed = 9; // our last closed ledger optional bytes ledgerClosed = 9; // our last closed ledger
optional bytes ledgerPrevious = 10; // the ledger before the last closed ledger optional bytes ledgerPrevious = 10; // the ledger before the last closed ledger
optional bool nodePrivate = 11; // Request to not forward IP.
} }