From 2f33f2ec2ba9177a91d8bd237475b298cdb8842e Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Thu, 6 Jul 2017 09:38:10 -0400 Subject: [PATCH] [FOLD] Address review comments --- src/ripple/app/consensus/RCLConsensus.cpp | 2 +- src/ripple/app/misc/NetworkOPs.cpp | 2 +- src/ripple/consensus/Consensus.h | 4 ++-- src/ripple/consensus/ConsensusTypes.h | 5 +++-- src/ripple/overlay/impl/PeerImp.cpp | 4 ++-- src/ripple/protocol/PublicKey.h | 6 ++++++ src/test/app/ValidatorKeys_test.cpp | 4 ---- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index 0cfdc66176e..43203538c94 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -466,7 +466,7 @@ RCLConsensus::Adaptor::doAccept( JLOG(j_.info()) << "CNF buildLCL " << newLCLHash; // See if we can accept a ledger as fully-validated - ledgerMaster_.consensusBuilt(sharedLCL.ledger_, consensusJson); + ledgerMaster_.consensusBuilt(sharedLCL.ledger_, std::move(consensusJson)); //------------------------------------------------------------------------- { diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 142db4d3774..cbf29dfcf45 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -2126,7 +2126,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) if (admin) { - if (app_.getValidationPublicKey().size ()) + if (!app_.getValidationPublicKey().empty()) { info[jss::pubkey_validator] = toBase58 ( TokenType::TOKEN_NODE_PUBLIC, diff --git a/src/ripple/consensus/Consensus.h b/src/ripple/consensus/Consensus.h index 85aaee60901..b2927c4e1c8 100644 --- a/src/ripple/consensus/Consensus.h +++ b/src/ripple/consensus/Consensus.h @@ -174,7 +174,7 @@ namespace ripple { Mode mode); // Called whenever consensus operating mode changes - void onModeChange(ConsensuMode before, ConsensusMode after); + void onModeChange(ConsensusMode before, ConsensusMode after); // Called when ledger closes Result onClose(Ledger const &, Ledger const & prev, Mode mode); @@ -426,7 +426,7 @@ class Consensus void updateDisputes(NodeID_t const& node, TxSet_t const& other); - //Revoke our outstanding proposal, if any, and cease proposing + // Revoke our outstanding proposal, if any, and cease proposing // until this round ends. void leaveConsensus(); diff --git a/src/ripple/consensus/ConsensusTypes.h b/src/ripple/consensus/ConsensusTypes.h index b65a1260435..c57ba597396 100644 --- a/src/ripple/consensus/ConsensusTypes.h +++ b/src/ripple/consensus/ConsensusTypes.h @@ -48,8 +48,9 @@ namespace ripple { We enter the round proposing or observing. If we detect we are working on the wrong prior ledger, we go to wrongLedger and attempt to acquire the right one. Once we acquire the right one, we go to the switchedLedger - mode. If we again detect the wrong ledger before this round ends, we go - back to wrongLedger until we acquire the right one. + mode. It is possible we fall behind again and find there is a new better + ledger, moving back and forth between wrongLedger and switchLedger as + we attempt to catch up. */ enum class ConsensusMode { //! We are normal participant in consensus and propose our position diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index 9157b34e3b6..a5554780fa6 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -1094,7 +1094,7 @@ PeerImp::onMessage (std::shared_ptr const& m) flags |= SF_TRUSTED; } - if (! app_.getValidationPublicKey().size()) + if (app_.getValidationPublicKey().empty()) { // For now, be paranoid and have each validator // check each transaction, regardless of source @@ -1256,7 +1256,7 @@ PeerImp::onMessage (std::shared_ptr const& m) return; } - if (app_.getValidationPublicKey().size() && + if (!app_.getValidationPublicKey().empty() && publicKey == app_.getValidationPublicKey()) { JLOG(p_journal_.trace()) << "Proposal: self"; diff --git a/src/ripple/protocol/PublicKey.h b/src/ripple/protocol/PublicKey.h index e4ec4721683..a093658bf0d 100644 --- a/src/ripple/protocol/PublicKey.h +++ b/src/ripple/protocol/PublicKey.h @@ -87,6 +87,12 @@ class PublicKey return size_; } + bool + empty() const noexcept + { + return size_ == 0; + } + Slice slice() const noexcept { diff --git a/src/test/app/ValidatorKeys_test.cpp b/src/test/app/ValidatorKeys_test.cpp index d6160d21e13..7fb8d32bfdc 100644 --- a/src/test/app/ValidatorKeys_test.cpp +++ b/src/test/app/ValidatorKeys_test.cpp @@ -81,7 +81,6 @@ class ValidatorKeys_test : public beast::unit_test::suite Config c; ValidatorKeys k{c, j}; BEAST_EXPECT(k.publicKey.size() == 0); - BEAST_EXPECT(k.secretKey.size() == 0); BEAST_EXPECT(k.manifest.empty()); BEAST_EXPECT(!k.configInvalid()); @@ -106,7 +105,6 @@ class ValidatorKeys_test : public beast::unit_test::suite ValidatorKeys k{c, j}; BEAST_EXPECT(k.configInvalid()); BEAST_EXPECT(k.publicKey.size() == 0); - BEAST_EXPECT(k.secretKey.size() == 0); BEAST_EXPECT(k.manifest.empty()); } @@ -128,7 +126,6 @@ class ValidatorKeys_test : public beast::unit_test::suite ValidatorKeys k{c, j}; BEAST_EXPECT(k.configInvalid()); BEAST_EXPECT(k.publicKey.size() == 0); - BEAST_EXPECT(k.secretKey.size() == 0); BEAST_EXPECT(k.manifest.empty()); } @@ -141,7 +138,6 @@ class ValidatorKeys_test : public beast::unit_test::suite BEAST_EXPECT(k.configInvalid()); BEAST_EXPECT(k.publicKey.size() == 0); - BEAST_EXPECT(k.secretKey.size() == 0); BEAST_EXPECT(k.manifest.empty()); }