Throws, explicits and trivial cleanups

This commit is contained in:
Miguel Portilla
2016-01-28 17:42:38 -05:00
committed by Nik Bougalis
parent 8e842b5893
commit ed9f5639a8
16 changed files with 15 additions and 18 deletions

View File

@@ -1782,7 +1782,6 @@ void LedgerConsensusImp::beginAccept (bool synchronous)
JLOG (j_.fatal) JLOG (j_.fatal)
<< "We don't have a consensus set"; << "We don't have a consensus set";
abort (); abort ();
return;
} }
consensus_.newLCL (mPeerPositions.size (), mCurrentMSeconds); consensus_.newLCL (mPeerPositions.size (), mCurrentMSeconds);

View File

@@ -1046,13 +1046,13 @@ void ApplicationImp::setup()
if (!cluster_->load (config().section(SECTION_CLUSTER_NODES))) if (!cluster_->load (config().section(SECTION_CLUSTER_NODES)))
{ {
m_journal.fatal << "Invalid entry in cluster configuration."; m_journal.fatal << "Invalid entry in cluster configuration.";
throw std::exception(); Throw<std::exception>();
} }
if (!validators_->load (config().section (SECTION_VALIDATORS))) if (!validators_->load (config().section (SECTION_VALIDATORS)))
{ {
m_journal.fatal << "Invalid entry in validator configuration."; m_journal.fatal << "Invalid entry in validator configuration.";
throw std::exception(); Throw<std::exception>();
} }
if (validators_->size () == 0 && !config_->RUN_STANDALONE) if (validators_->size () == 0 && !config_->RUN_STANDALONE)

View File

@@ -38,7 +38,7 @@ loadNodeIdentity (Application& app)
app.config().NODE_SEED); app.config().NODE_SEED);
if (!seed) if (!seed)
throw std::runtime_error ( Throw<std::runtime_error>(
"NodeIdentity: Bad [node_seed] specified"); "NodeIdentity: Bad [node_seed] specified");
auto secretKey = auto secretKey =

View File

@@ -74,6 +74,7 @@ private:
} }
public: public:
explicit
ValidationsImp (Application& app) ValidationsImp (Application& app)
: app_ (app) : app_ (app)
, mValidations ("Validations", 4096, 600, stopwatch(), , mValidations ("Validations", 4096, 600, stopwatch(),

View File

@@ -365,7 +365,7 @@ void Config::loadFromString (std::string const& fileContents)
{ {
auto const seed = parseBase58<Seed>(strTemp); auto const seed = parseBase58<Seed>(strTemp);
if (!seed) if (!seed)
throw std::runtime_error ( Throw<std::runtime_error> (
"Invalid seed specified in [" SECTION_VALIDATION_SEED "]"); "Invalid seed specified in [" SECTION_VALIDATION_SEED "]");
VALIDATION_PRIV = generateSecretKey (KeyType::secp256k1, *seed); VALIDATION_PRIV = generateSecretKey (KeyType::secp256k1, *seed);
VALIDATION_PUB = derivePublicKey (KeyType::secp256k1, VALIDATION_PRIV); VALIDATION_PUB = derivePublicKey (KeyType::secp256k1, VALIDATION_PRIV);
@@ -374,7 +374,7 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_NODE_SEED, NODE_SEED, j_)) if (getSingleSection (secConfig, SECTION_NODE_SEED, NODE_SEED, j_))
{ {
if (!parseBase58<Seed>(NODE_SEED)) if (!parseBase58<Seed>(NODE_SEED))
throw std::runtime_error ( Throw<std::runtime_error> (
"Invalid seed specified in [" SECTION_NODE_SEED "]"); "Invalid seed specified in [" SECTION_NODE_SEED "]");
} }

View File

@@ -341,7 +341,6 @@ public:
ledgerHashes.emplace_back(lh); ledgerHashes.emplace_back(lh);
ledgerIndexes.emplace_back(i); ledgerIndexes.emplace_back(i);
} }
std::string slh (lh);
s << "INSERT INTO Ledgers (LedgerHash, LedgerSeq) VALUES " s << "INSERT INTO Ledgers (LedgerHash, LedgerSeq) VALUES "
"(:lh, :li);", "(:lh, :li);",
soci::use (ledgerHashes), soci::use (ledgerIndexes); soci::use (ledgerHashes), soci::use (ledgerIndexes);

View File

@@ -76,6 +76,7 @@ size_t lengthWithoutTrailingZeros (std::string const& s)
class Writer::Impl class Writer::Impl
{ {
public: public:
explicit
Impl (Output const& output) : output_(output) {} Impl (Output const& output) : output_(output) {}
~Impl() = default; ~Impl() = default;

View File

@@ -31,6 +31,7 @@ private:
boost::optional<uint256> digest_; boost::optional<uint256> digest_;
public: public:
explicit
Impl (DigestAwareReadView const& ledger) Impl (DigestAwareReadView const& ledger)
{ {
auto const k = keylet::amendments(); auto const k = keylet::amendments();

View File

@@ -1360,9 +1360,8 @@ rippleSend (ApplyView& view,
if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount()) if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount())
{ {
// VFALCO Why do we need this bCheckIssuer?
// Direct send: redeeming IOUs and/or sending own IOUs. // Direct send: redeeming IOUs and/or sending own IOUs.
terResult = rippleCredit (view, uSenderID, uReceiverID, saAmount, false, j); rippleCredit (view, uSenderID, uReceiverID, saAmount, false, j);
saActual = saAmount; saActual = saAmount;
terResult = tesSUCCESS; terResult = tesSUCCESS;
} }

View File

@@ -40,6 +40,7 @@ namespace ripple {
class HTTPClientSSLContext class HTTPClientSSLContext
{ {
public: public:
explicit
HTTPClientSSLContext (Config const& config) HTTPClientSSLContext (Config const& config)
: m_context (boost::asio::ssl::context::sslv23) : m_context (boost::asio::ssl::context::sslv23)
, verify_ (config.SSL_VERIFY) , verify_ (config.SSL_VERIFY)

View File

@@ -1066,7 +1066,7 @@ setup_Overlay (BasicConfig const& config)
set (setup.ipLimit, "ip_limit", section); set (setup.ipLimit, "ip_limit", section);
if (setup.ipLimit < 0) if (setup.ipLimit < 0)
throw std::runtime_error ("Configured IP limit is invalid"); Throw<std::runtime_error> ("Configured IP limit is invalid");
std::string ip; std::string ip;
set (ip, "public_ip", section); set (ip, "public_ip", section);

View File

@@ -132,10 +132,7 @@ std::string const& getFullVersionString ()
{ {
struct PrettyPrinter struct PrettyPrinter
{ {
PrettyPrinter () PrettyPrinter () : fullVersionString ("rippled-" + getVersionString ()){}
{
fullVersionString = "rippled-" + getVersionString ();
}
std::string fullVersionString; std::string fullVersionString;
}; };

View File

@@ -48,7 +48,7 @@ STAccount::STAccount (SField const& n, Buffer&& v)
// which throws. If STVar can throw in its constructor, then so can // which throws. If STVar can throw in its constructor, then so can
// STAccount. // STAccount.
if (v.size() != uint160::bytes) if (v.size() != uint160::bytes)
throw std::runtime_error ("Invalid STAccount size"); Throw<std::runtime_error> ("Invalid STAccount size");
default_ = false; default_ = false;
memcpy (value_.begin(), v.data (), uint160::bytes); memcpy (value_.begin(), v.data (), uint160::bytes);

View File

@@ -59,6 +59,7 @@ Status handle (Context& context, Object& object)
class HandlerTable { class HandlerTable {
public: public:
template<std::size_t N> template<std::size_t N>
explicit
HandlerTable (const Handler(&entries)[N]) HandlerTable (const Handler(&entries)[N])
{ {
for (std::size_t i = 0; i < N; ++i) for (std::size_t i = 0; i < N; ++i)

View File

@@ -54,8 +54,6 @@ std::string Status::codeString () const
void Status::fillJson (Json::Value& value) void Status::fillJson (Json::Value& value)
{ {
static const std::string separator = ": ";
if (!*this) if (!*this)
return; return;