From f65cea66ef99b1de149c02c15f06de6c61abf360 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Sun, 14 Sep 2014 17:36:01 -0700 Subject: [PATCH] Remove unused macros, config variables, and file --- Builds/VisualStudio2013/RippleD.vcxproj | 5 - .../VisualStudio2013/RippleD.vcxproj.filters | 6 - src/ripple/app/transactors/SetAccount.cpp | 3 + src/ripple/core/Config.h | 103 ++------------- src/ripple/core/ConfigSections.h | 9 +- src/ripple/core/impl/Config.cpp | 40 ++---- src/ripple/rpc/RPCHandler.h | 1 - src/ripple/rpc/impl/Authorize.cpp | 121 ------------------ src/ripple/rpc/impl/Authorize.h | 41 ------ src/ripple/unity/rpcx.cpp | 3 - 10 files changed, 23 insertions(+), 309 deletions(-) delete mode 100644 src/ripple/rpc/impl/Authorize.cpp delete mode 100644 src/ripple/rpc/impl/Authorize.h diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index abb06345f..399ed919b 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -3183,11 +3183,6 @@ - - True - - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 5896d4411..8d46b985f 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -4377,12 +4377,6 @@ ripple\rpc\impl - - ripple\rpc\impl - - - ripple\rpc\impl - ripple\rpc\impl diff --git a/src/ripple/app/transactors/SetAccount.cpp b/src/ripple/app/transactors/SetAccount.cpp index 2a79dc345..40a88f8b1 100644 --- a/src/ripple/app/transactors/SetAccount.cpp +++ b/src/ripple/app/transactors/SetAccount.cpp @@ -24,6 +24,9 @@ namespace ripple { class SetAccount : public Transactor { + static int const DOMAIN_BYTES_MAX = 256; + static int const PUBLIC_BYTES_MAX = 33; + public: SetAccount ( SerializedTransaction const& txn, diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index c30cd5584..6abad70af 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -163,30 +163,7 @@ get (Section const& section, #define SYSTEM_CURRENCY_PARTS 1000000ull // 10^SYSTEM_CURRENCY_PRECISION #define SYSTEM_CURRENCY_START (SYSTEM_CURRENCY_GIFT*SYSTEM_CURRENCY_USERS*SYSTEM_CURRENCY_PARTS) -const int DOMAIN_BYTES_MAX = 256; -const int PUBLIC_BYTES_MAX = 33; // Maximum bytes for an account public key. - -const int SYSTEM_PEER_PORT = 6561; -const int SYSTEM_WEBSOCKET_PORT = 6562; -const int SYSTEM_WEBSOCKET_PUBLIC_PORT = 6563; // XXX Going away. - -// Allow anonymous DH. -#define DEFAULT_PEER_SSL_CIPHER_LIST "ALL:!LOW:!EXP:!MD5:@STRENGTH" - -// Normal, recommend 1 hour: 60*60 -// Testing, recommend 1 minute: 60 -#define DEFAULT_PEER_SCAN_INTERVAL_MIN (60*60) // Seconds - -// Maximum number of peers to try to connect to as client at once. -#define DEFAULT_PEER_START_MAX 5 - -// Might connect with fewer for testing. -#define DEFAULT_PEER_CONNECT_LOW_WATER 10 - -#define DEFAULT_PATH_SEARCH_OLD 7 -#define DEFAULT_PATH_SEARCH 7 -#define DEFAULT_PATH_SEARCH_FAST 2 -#define DEFAULT_PATH_SEARCH_MAX 10 +const int SYSTEM_PEER_PORT = 6561; enum SizedItemName { @@ -221,8 +198,6 @@ struct SizedItem class Config : public BasicConfig { public: - - struct Helpers { // This replaces CONFIG_FILE_NAME @@ -242,65 +217,6 @@ public: } }; - /** The result of performing a load on the parsed config file data. - This type is convertible to `bool`. - A value of `true` indicates an error occurred, - while `false` indicates no error. - */ - class Error - { - public: - Error () noexcept - : m_what (beast::String::empty) - , m_fileName ("") - , m_lineNumber (0) - { - } - - Error (beast::String what, char const* fileName, int lineNumber) noexcept - : m_what (what) - , m_fileName (fileName) - , m_lineNumber (lineNumber) - { - } - - explicit - operator bool() const noexcept - { - return m_what != beast::String::empty; - } - - beast::String what () const noexcept - { - return m_what; - } - - char const* fileName () const - { - return m_fileName; - } - - int lineNumber () const - { - return m_lineNumber; - } - - private: - beast::String m_what; - char const* m_fileName; - int m_lineNumber; - }; - - /** Listening socket settings. */ - struct DoorSettings - { - /** Create a default set of door (listening socket) settings. */ - DoorSettings (); - - /** Load settings from the configuration file. */ - //Error load (ParsedConfigFile const& file); - }; - //-------------------------------------------------------------------------- // Settings related to the configuration file location and directories @@ -499,10 +415,7 @@ public: std::string DATABASE_PATH; // Network parameters - int NETWORK_START_TIME; // The Unix time we start ledger 0. int TRANSACTION_FEE_BASE; // The number of fee units a reference transaction costs - int LEDGER_SECONDS; - bool LEDGER_CREATOR; // Should be false unless we are starting a new ledger. /** Operate in stand-alone mode. @@ -521,11 +434,7 @@ public: // Peer networking parameters std::string PEER_IP; - int NUMBER_CONNECTIONS; std::string PEER_SSL_CIPHER_LIST; - 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. unsigned int PEERS_MAX; @@ -569,18 +478,22 @@ public: int PATH_SEARCH_MAX; // Validation - RippleAddress VALIDATION_SEED, VALIDATION_PUB, VALIDATION_PRIV; + RippleAddress VALIDATION_SEED; + RippleAddress VALIDATION_PUB; + RippleAddress VALIDATION_PRIV; // Node/Cluster std::vector CLUSTER_NODES; - RippleAddress NODE_SEED, NODE_PUB, NODE_PRIV; + RippleAddress NODE_SEED; + RippleAddress NODE_PUB; + RippleAddress NODE_PRIV; // Fee schedule (All below values are in fee units) std::uint64_t FEE_DEFAULT; // Default fee. std::uint64_t FEE_ACCOUNT_RESERVE; // Amount of units not allowed to send. std::uint64_t FEE_OWNER_RESERVE; // Amount of units not allowed to send per owner entry. std::uint64_t FEE_OFFER; // Rate per day. - int FEE_CONTRACT_OPERATION; // fee for each contract operation + int FEE_CONTRACT_OPERATION; // fee for each contract operation // Node storage configuration std::uint32_t LEDGER_HISTORY; diff --git a/src/ripple/core/ConfigSections.h b/src/ripple/core/ConfigSections.h index 53f6975d9..2d5c11d5b 100644 --- a/src/ripple/core/ConfigSections.h +++ b/src/ripple/core/ConfigSections.h @@ -58,15 +58,12 @@ struct ConfigSection #define SECTION_PATH_SEARCH "path_search" #define SECTION_PATH_SEARCH_FAST "path_search_fast" #define SECTION_PATH_SEARCH_MAX "path_search_max" -#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_PROXY_PORT "peer_port_proxy" #define SECTION_PEER_PRIVATE "peer_private" #define SECTION_PEERS_MAX "peers_max" -#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" #define SECTION_RPC_ALLOW_REMOTE "rpc_allow_remote" #define SECTION_RPC_ADMIN_ALLOW "rpc_admin_allow" #define SECTION_RPC_ADMIN_USER "rpc_admin_user" @@ -95,9 +92,9 @@ struct ConfigSection #define SECTION_WEBSOCKET_PUBLIC_IP "websocket_public_ip" #define SECTION_WEBSOCKET_PUBLIC_PORT "websocket_public_port" #define SECTION_WEBSOCKET_PUBLIC_SECURE "websocket_public_secure" -#define SECTION_WEBSOCKET_PROXY_IP "websocket_proxy_ip" -#define SECTION_WEBSOCKET_PROXY_PORT "websocket_proxy_port" -#define SECTION_WEBSOCKET_PROXY_SECURE "websocket_proxy_secure" +#define SECTION_WEBSOCKET_PROXY_IP "websocket_proxy_ip" +#define SECTION_WEBSOCKET_PROXY_PORT "websocket_proxy_port" +#define SECTION_WEBSOCKET_PROXY_SECURE "websocket_proxy_secure" #define SECTION_WEBSOCKET_PING_FREQ "websocket_ping_frequency" #define SECTION_WEBSOCKET_IP "websocket_ip" #define SECTION_WEBSOCKET_PORT "websocket_port" diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index d7d9166db..e18cd04e4 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -332,30 +332,20 @@ Config::Config () // Defaults // - NETWORK_START_TIME = 1319844908; - RPC_SECURE = 0; - WEBSOCKET_PORT = SYSTEM_WEBSOCKET_PORT; - WEBSOCKET_PUBLIC_PORT = SYSTEM_WEBSOCKET_PUBLIC_PORT; + WEBSOCKET_PORT = 6562; + WEBSOCKET_PUBLIC_PORT = 6563; WEBSOCKET_PUBLIC_SECURE = 1; WEBSOCKET_PROXY_PORT = 0; WEBSOCKET_PROXY_SECURE = 1; WEBSOCKET_SECURE = 0; WEBSOCKET_PING_FREQ = (5 * 60); - NUMBER_CONNECTIONS = 30; - - // a new ledger every minute - LEDGER_SECONDS = 60; - LEDGER_CREATOR = false; RPC_ALLOW_REMOTE = false; RPC_ADMIN_ALLOW.push_back (beast::IP::Endpoint::from_string("127.0.0.1")); - PEER_SSL_CIPHER_LIST = DEFAULT_PEER_SSL_CIPHER_LIST; - PEER_SCAN_INTERVAL_MIN = DEFAULT_PEER_SCAN_INTERVAL_MIN; - - PEER_START_MAX = DEFAULT_PEER_START_MAX; - PEER_CONNECT_LOW_WATER = DEFAULT_PEER_CONNECT_LOW_WATER; + // By default, allow anonymous DH. + PEER_SSL_CIPHER_LIST = "ALL:!LOW:!EXP:!MD5:@STRENGTH"; PEER_PRIVATE = false; PEERS_MAX = 0; // indicates "use default" @@ -374,10 +364,11 @@ Config::Config () LEDGER_HISTORY = 256; FETCH_DEPTH = 1000000000; - PATH_SEARCH_OLD = DEFAULT_PATH_SEARCH_OLD; - PATH_SEARCH = DEFAULT_PATH_SEARCH; - PATH_SEARCH_FAST = DEFAULT_PATH_SEARCH_FAST; - PATH_SEARCH_MAX = DEFAULT_PATH_SEARCH_MAX; + // An explanation of these magical values would be nice. + PATH_SEARCH_OLD = 7; + PATH_SEARCH = 7; + PATH_SEARCH_FAST = 2; + PATH_SEARCH_MAX = 10; ACCOUNT_PROBE_MAX = 10; @@ -652,9 +643,6 @@ void Config::load () if (getSingleSection (secConfig, SECTION_RPC_PORT, strTemp)) m_rpcPort = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, "ledger_creator" , strTemp)) - LEDGER_CREATOR = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp)) RPC_ALLOW_REMOTE = beast::lexicalCastThrow (strTemp); @@ -753,16 +741,6 @@ void Config::load () (void) getSingleSection (secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST); - if (getSingleSection (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp)) - // Minimum for min is 60 seconds. - PEER_SCAN_INTERVAL_MIN = std::max (60, beast::lexicalCastThrow (strTemp)); - - if (getSingleSection (secConfig, SECTION_PEER_START_MAX, strTemp)) - PEER_START_MAX = std::max (1, beast::lexicalCastThrow (strTemp)); - - if (getSingleSection (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp)) - PEER_CONNECT_LOW_WATER = std::max (1, beast::lexicalCastThrow (strTemp)); - if (getSingleSection (secConfig, SECTION_NETWORK_QUORUM, strTemp)) NETWORK_QUORUM = beast::lexicalCastThrow (strTemp); diff --git a/src/ripple/rpc/RPCHandler.h b/src/ripple/rpc/RPCHandler.h index b0864f208..93fc2065d 100644 --- a/src/ripple/rpc/RPCHandler.h +++ b/src/ripple/rpc/RPCHandler.h @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/src/ripple/rpc/impl/Authorize.cpp b/src/ripple/rpc/impl/Authorize.cpp deleted file mode 100644 index 022eae17e..000000000 --- a/src/ripple/rpc/impl/Authorize.cpp +++ /dev/null @@ -1,121 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012-2014 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include - -namespace ripple { -namespace RPC { - -// Given a seed and a source account get the regular public and private key for authorizing transactions. -// - Make sure the source account can pay. -// --> naRegularSeed : To find the generator -// --> naSrcAccountID : Account we want the public and private regular keys to. -// <-- naAccountPublic : Regular public key for naSrcAccountID -// <-- naAccountPrivate : Regular private key for naSrcAccountID -// <-- saSrcBalance: Balance minus fee. -// --> naVerifyGenerator : If provided, the found master public generator must match. -// XXX Be more lenient, allow use of master generator on claimed accounts. -Json::Value authorize (Ledger::ref lrLedger, - RippleAddress const& naRegularSeed, RippleAddress const& naSrcAccountID, - RippleAddress& naAccountPublic, RippleAddress& naAccountPrivate, - STAmount& saSrcBalance, STAmount const& saFee, AccountState::pointer& asSrc, - RippleAddress const& naVerifyGenerator, NetworkOPs& netOps) -{ - // Source/paying account must exist. - asSrc = netOps.getAccountState (lrLedger, naSrcAccountID); - - if (!asSrc) - { - return rpcError (rpcSRC_ACT_NOT_FOUND); - } - - RippleAddress naMasterGenerator; - - if (asSrc->haveAuthorizedKey ()) - { - Json::Value obj = getMasterGenerator (lrLedger, naRegularSeed, naMasterGenerator, netOps); - - if (!obj.empty ()) - return obj; - } - else - { - // Try the seed as a master seed. - naMasterGenerator = RippleAddress::createGeneratorPublic (naRegularSeed); - } - - // If naVerifyGenerator is provided, make sure it is the master generator. - if (naVerifyGenerator.isValid () && naMasterGenerator != naVerifyGenerator) - { - return rpcError (rpcWRONG_SEED); - } - - // Find the index of the account from the master generator, so we can generate the public and private keys. - RippleAddress naMasterAccountPublic; - unsigned int iIndex = 0; - bool bFound = false; - - // Don't look at ledger entries to determine if the account exists. Don't want to leak to thin server that these accounts are - // related. - while (!bFound && iIndex != getConfig ().ACCOUNT_PROBE_MAX) - { - naMasterAccountPublic.setAccountPublic (naMasterGenerator, iIndex); - - WriteLog (lsDEBUG, RPCHandler) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID () << " : " << naSrcAccountID.humanAccountID (); - - bFound = naSrcAccountID.getAccountID () == naMasterAccountPublic.getAccountID (); - - if (!bFound) - ++iIndex; - } - - if (!bFound) - { - return rpcError (rpcACT_NOT_FOUND); - } - - // Use the regular generator to determine the associated public and private keys. - RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naRegularSeed); - - naAccountPublic.setAccountPublic (naGenerator, iIndex); - naAccountPrivate.setAccountPrivate (naGenerator, naRegularSeed, iIndex); - - if (asSrc->haveAuthorizedKey () && (asSrc->getAuthorizedKey ().getAccountID () != naAccountPublic.getAccountID ())) - { - return rpcError (rpcPASSWD_CHANGED); - } - - saSrcBalance = asSrc->getBalance (); - - if (saSrcBalance < saFee) - { - WriteLog (lsINFO, RPCHandler) << "authorize: Insufficient funds for fees: fee=" << saFee.getText () << " balance=" << saSrcBalance.getText (); - - return rpcError (rpcINSUF_FUNDS); - } - else - { - saSrcBalance -= saFee; - } - - return Json::Value (); -} - -} // RPC -} // ripple diff --git a/src/ripple/rpc/impl/Authorize.h b/src/ripple/rpc/impl/Authorize.h deleted file mode 100644 index ce8f70890..000000000 --- a/src/ripple/rpc/impl/Authorize.h +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012-2014 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_RPC_AUTHORIZE_H_INCLUDED -#define RIPPLE_RPC_AUTHORIZE_H_INCLUDED - -namespace ripple { -namespace RPC { - -Json::Value authorize ( - Ledger::ref lrLedger, - RippleAddress const& naRegularSeed, - RippleAddress const& naSrcAccountID, - RippleAddress& naAccountPublic, - RippleAddress& naAccountPrivate, - STAmount& saSrcBalance, - STAmount const& saFee, - AccountState::pointer& asSrc, - RippleAddress const& naVerifyGenerator, - NetworkOPs& netOps); - -} // RPC -} // ripple - -#endif diff --git a/src/ripple/unity/rpcx.cpp b/src/ripple/unity/rpcx.cpp index 920a96f19..0da772201 100644 --- a/src/ripple/unity/rpcx.cpp +++ b/src/ripple/unity/rpcx.cpp @@ -17,8 +17,6 @@ */ //============================================================================== -#include - #include // Unfortunate but necessary since RPC handlers can literally do anything @@ -101,7 +99,6 @@ #include #include -#include #include #include #include