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

View File

@@ -20,6 +20,7 @@
#define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water"
#define SECTION_PEER_IP "peer_ip"
#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_SSL_CIPHER_LIST "peer_ssl_cipher_list"
#define SECTION_PEER_START_MAX "peer_start_max"
@@ -27,7 +28,7 @@
#define SECTION_RPC_IP "rpc_ip"
#define SECTION_RPC_PORT "rpc_port"
#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_SEED "validation_seed"
#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_CONNECT_LOW_WATER = DEFAULT_PEER_CONNECT_LOW_WATER;
PEER_PRIVATE = false;
TRANSACTION_FEE_BASE = 1000;
NETWORK_QUORUM = 0; // Don't need to see other nodes
@@ -222,6 +225,9 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_PEER_PORT, 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);
if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp))
@@ -292,8 +298,8 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp))
ACCOUNT_PROBE_MAX = boost::lexical_cast<int>(strTemp);
if (sectionSingleB(secConfig, SECTION_UNL_DEFAULT, strTemp))
UNL_DEFAULT = strTemp;
if (sectionSingleB(secConfig, SECTION_VALIDATORS_FILE, strTemp))
VALIDATORS_FILE = strTemp;
if (sectionSingleB(secConfig, SECTION_DEBUG_LOGFILE, strTemp))
DEBUG_LOGFILE = strTemp;

View File

@@ -50,7 +50,7 @@ public:
boost::filesystem::path CONFIG_DIR;
boost::filesystem::path DATA_DIR;
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::vector<std::string> VALIDATORS; // Validators from rippled.cfg.
@@ -66,7 +66,7 @@ public:
int LEDGER_SECONDS;
int LEDGER_PROPOSAL_DELAY_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;
// 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_START_MAX;
unsigned int PEER_CONNECT_LOW_WATER;
bool PEER_PRIVATE; // True to ask peers not to relay current IP.
// Websocket networking parameters
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)
return;
{
Database* db = theApp->getWalletDB()->getDB();
ScopedLock sl(theApp->getWalletDB()->getDBLock());

View File

@@ -430,24 +430,29 @@ void Peer::processReadBuffer()
case ripple::mtCONTACT:
{
ripple::TMContact msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvContact(msg);
else
cLog(lsWARNING) << "parse error: " << type;
}
break;
case ripple::mtGET_PEERS:
{
ripple::TMGetPeers msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetPeers(msg);
else
cLog(lsWARNING) << "parse error: " << type;
}
break;
case ripple::mtPEERS:
{
ripple::TMPeers msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvPeers(msg);
else
@@ -666,7 +671,17 @@ void Peer::recvHello(ripple::TMHello& packet)
std::string strIP = getSocket().remote_endpoint().address().to_string();
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.
@@ -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 the peer you are talking to
void Peer::recvGetPeers(ripple::TMGetPeers& packet)
@@ -1510,6 +1525,7 @@ void Peer::sendHello()
h.set_nodepublic(theApp->getWallet().getNodePublic().humanNodePublic());
h.set_nodeproof(&vchSig[0], vchSig.size());
h.set_ipv4port(theConfig.PEER_PORT);
h.set_nodeprivate(theConfig.PEER_PRIVATE);
Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger();
if (closedLedger && closedLedger->isClosed())
@@ -1526,7 +1542,7 @@ void Peer::sendHello()
void Peer::sendGetPeers()
{
// get other peers this guy knows about
// Ask peer for known other peers.
ripple::TMGetPeers getPeers;
getPeers.set_doweneedthis(1);

View File

@@ -49,6 +49,7 @@ private:
ipPort mIpPortConnect;
uint256 mCookieHash;
uint64 mPeerId;
bool mPrivate; // Keep peer IP private.
uint256 mClosedLedgerHash, mPreviousLedgerHash;
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.
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);
}

View File

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

View File

@@ -1576,15 +1576,15 @@ void UniqueNodeList::nodeBootstrap()
bool bLoaded = iDomains || iNodes;
// 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.";
bLoaded = nodeLoad(theConfig.UNL_DEFAULT);
bLoaded = nodeLoad(theConfig.VALIDATORS_FILE);
}
// 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 "'.";

View File

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