Use cluster state in Slot instead of PeerImp

This commit is contained in:
Vinnie Falco
2014-11-24 07:11:09 -08:00
committed by Nik Bougalis
parent cd8ec89cbb
commit fb0d44d403
5 changed files with 41 additions and 51 deletions

View File

@@ -93,7 +93,7 @@ PeerImp::PeerImp (id_t id, beast::IP::Endpoint remoteAddress,
PeerImp::~PeerImp ()
{
if (clusterNode_)
if (cluster())
if (journal_.warning) journal_.warning <<
name_ << " left cluster";
if (state_ == State::active)
@@ -192,7 +192,7 @@ PeerImp::json()
if (m_inbound)
ret["inbound"] = true;
if (clusterNode_)
if (cluster())
{
ret["cluster"] = true;
@@ -708,13 +708,13 @@ PeerImp::processResponse (beast::http::message const& m,
"Protocol: " << to_string(protocol);
if(journal_.info) journal_.info <<
"Public Key: " << publicKey_.humanNodePublic();
clusterNode_ = getApp().getUNL().nodeInCluster(publicKey_, name_);
if (clusterNode_)
bool const cluster = getApp().getUNL().nodeInCluster(publicKey_, name_);
if (cluster)
if (journal_.info) journal_.info <<
"Cluster name: " << name_;
auto const result = overlay_.peerFinder().activate (slot_,
RipplePublicKey(publicKey_), clusterNode_);
auto const result = overlay_.peerFinder().activate (
slot_, RipplePublicKey(publicKey_), cluster);
if (result != PeerFinder::Result::success)
return fail("Outbound slots full");
@@ -787,8 +787,8 @@ void PeerImp::doAccept()
"Protocol: " << to_string(protocol);
if(journal_.info) journal_.info <<
"Public Key: " << publicKey_.humanNodePublic();
clusterNode_ = getApp().getUNL().nodeInCluster(publicKey_, name_);
if (clusterNode_)
bool const cluster = getApp().getUNL().nodeInCluster(publicKey_, name_);
if (cluster)
if (journal_.info) journal_.info <<
"Cluster name: " << name_;
@@ -1075,8 +1075,8 @@ PeerImp::on_message (std::shared_ptr <protocol::TMHello> const& m)
"Protocol: " << to_string(protocol);
if(journal_.info) journal_.info <<
"Public Key: " << publicKey_.humanNodePublic();
clusterNode_ = getApp().getUNL().nodeInCluster(publicKey_, name_);
if (clusterNode_)
bool const cluster = getApp().getUNL().nodeInCluster(publicKey_, name_);
if (cluster)
if (journal_.info) journal_.info <<
"Cluster name: " << name_;
@@ -1086,7 +1086,7 @@ PeerImp::on_message (std::shared_ptr <protocol::TMHello> const& m)
hello_ = *m;
auto const result = overlay_.peerFinder().activate (slot_,
RipplePublicKey (publicKey_), clusterNode_);
RipplePublicKey (publicKey_), cluster);
if (result == PeerFinder::Result::success)
{
@@ -1236,7 +1236,8 @@ PeerImp::error_code
PeerImp::on_message (std::shared_ptr <protocol::TMCluster> const& m)
{
error_code ec;
if (!clusterNode_)
// VFALCO NOTE I think we should drop the peer immediately
if (! cluster())
{
charge (Resource::feeUnwantedData);
return ec;
@@ -1387,7 +1388,7 @@ PeerImp::on_message (std::shared_ptr <protocol::TMTransaction> const& m)
p_journal_.debug <<
"Got tx " << txID;
if (clusterNode_)
if (cluster())
{
if (! m->has_deferred () || ! m->deferred ())
{
@@ -2053,7 +2054,7 @@ PeerImp::checkPropose (Job& job,
"proposal with previous ledger";
memcpy (prevLedger.begin (), set.previousledger ().data (), 256 / 8);
if (!clusterNode_ && !proposal->checkSign (set.signature ()))
if (! cluster() && !proposal->checkSign (set.signature ()))
{
p_journal_.warning <<
"Proposal with previous ledger fails sig check";
@@ -2114,7 +2115,7 @@ PeerImp::checkValidation (Job&, STValidation::pointer val,
{
// VFALCO Which functions throw?
uint256 signingHash = val->getSigningHash();
if (!clusterNode_ && !val->isValid (signingHash))
if (! cluster() && !val->isValid (signingHash))
{
p_journal_.warning <<
"Validation is invalid";
@@ -2248,7 +2249,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
}
else
{
if (getApp().getFeeTrack().isLoadedLocal() && !clusterNode_)
if (getApp().getFeeTrack().isLoadedLocal() && ! cluster())
{
p_journal_.debug <<
"GetLedger: Too busy";