diff --git a/src/cpp/ripple/LedgerMaster.cpp b/src/cpp/ripple/LedgerMaster.cpp index 5a26e30bb3..de1a90a8bd 100644 --- a/src/cpp/ripple/LedgerMaster.cpp +++ b/src/cpp/ripple/LedgerMaster.cpp @@ -350,8 +350,8 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const& if (nextLedger) { - ripple::TMGetObjectByHash tmBH; - tmBH.set_type (ripple::TMGetObjectByHash::otFETCH_PACK); + protocol::TMGetObjectByHash tmBH; + tmBH.set_type (protocol::TMGetObjectByHash::otFETCH_PACK); tmBH.set_query (true); tmBH.set_seq (ledgerSeq); tmBH.set_ledgerhash (ledgerHash.begin (), 32); @@ -373,7 +373,7 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const& if (target) { - PackedMessage::pointer packet = boost::make_shared (tmBH, ripple::mtGET_OBJECTS); + PackedMessage::pointer packet = boost::make_shared (tmBH, protocol::mtGET_OBJECTS); target->sendPacket (packet, false); } else diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 12b917bfdf..34d1fa9b29 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -295,14 +295,14 @@ void NetworkOPs::runTransactionQueue () if (theApp->getHashRouter ().swapSet (txn->getID (), peers, SF_RELAYED)) { - ripple::TMTransaction tx; + protocol::TMTransaction tx; Serializer s; dbtx->getSTransaction ()->add (s); tx.set_rawtransaction (&s.getData ().front (), s.getLength ()); - tx.set_status (ripple::tsCURRENT); + tx.set_status (protocol::tsCURRENT); tx.set_receivetimestamp (getNetworkTimeNC ()); // FIXME: This should be when we received it - PackedMessage::pointer packet = boost::make_shared (tx, ripple::mtTRANSACTION); + PackedMessage::pointer packet = boost::make_shared (tx, protocol::mtTRANSACTION); theApp->getPeers ().relayMessageBut (peers, packet); } } @@ -404,14 +404,14 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans, if (theApp->getHashRouter ().swapSet (trans->getID (), peers, SF_RELAYED)) { - ripple::TMTransaction tx; + protocol::TMTransaction tx; Serializer s; trans->getSTransaction ()->add (s); tx.set_rawtransaction (&s.getData ().front (), s.getLength ()); - tx.set_status (ripple::tsCURRENT); + tx.set_status (protocol::tsCURRENT); tx.set_receivetimestamp (getNetworkTimeNC ()); // FIXME: This should be when we received it - PackedMessage::pointer packet = boost::make_shared (tx, ripple::mtTRANSACTION); + PackedMessage::pointer packet = boost::make_shared (tx, protocol::mtTRANSACTION); theApp->getPeers ().relayMessageBut (peers, packet); } } @@ -856,15 +856,15 @@ void NetworkOPs::switchLastClosedLedger (Ledger::pointer newLedger, bool duringC Ledger::pointer openLedger = boost::make_shared (false, boost::ref (*newLedger)); mLedgerMaster->switchLedgers (newLedger, openLedger); - ripple::TMStatusChange s; - s.set_newevent (ripple::neSWITCHED_LEDGER); + protocol::TMStatusChange s; + s.set_newevent (protocol::neSWITCHED_LEDGER); s.set_ledgerseq (newLedger->getLedgerSeq ()); s.set_networktime (theApp->getOPs ().getNetworkTimeNC ()); uint256 hash = newLedger->getParentHash (); s.set_ledgerhashprevious (hash.begin (), hash.size ()); hash = newLedger->getHash (); s.set_ledgerhash (hash.begin (), hash.size ()); - PackedMessage::pointer packet = boost::make_shared (s, ripple::mtSTATUS_CHANGE); + PackedMessage::pointer packet = boost::make_shared (s, protocol::mtSTATUS_CHANGE); theApp->getPeers ().relayMessage (NULL, packet); } @@ -935,7 +935,7 @@ uint256 NetworkOPs::getConsensusLCL () } void NetworkOPs::processTrustedProposal (LedgerProposal::pointer proposal, - boost::shared_ptr set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood) + boost::shared_ptr set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood) { boost::recursive_mutex::scoped_lock sl (theApp->getMasterLock ()); @@ -975,7 +975,7 @@ void NetworkOPs::processTrustedProposal (LedgerProposal::pointer proposal, { std::set peers; theApp->getHashRouter ().swapSet (proposal->getHashRouter (), peers, SF_RELAYED); - PackedMessage::pointer message = boost::make_shared (*set, ripple::mtPROPOSE_LEDGER); + PackedMessage::pointer message = boost::make_shared (*set, protocol::mtPROPOSE_LEDGER); theApp->getPeers ().relayMessageBut (peers, message); } else @@ -1028,7 +1028,7 @@ SHAMapAddNode NetworkOPs::gotTXData (const boost::shared_ptr& peer, uint25 return mConsensus->peerGaveNodes (peer, hash, nodeIDs, nodeData); } -bool NetworkOPs::hasTXSet (const boost::shared_ptr& peer, uint256 const& set, ripple::TxSetStatus status) +bool NetworkOPs::hasTXSet (const boost::shared_ptr& peer, uint256 const& set, protocol::TxSetStatus status) { if (!haveConsensusObject ()) { @@ -2130,17 +2130,17 @@ void NetworkOPs::getBookPage (Ledger::pointer lpLedger, const uint160& uTakerPay // jvResult["nodes"] = Json::Value(Json::arrayValue); } -static void fpAppender (ripple::TMGetObjectByHash* reply, uint32 ledgerSeq, +static void fpAppender (protocol::TMGetObjectByHash* reply, uint32 ledgerSeq, const uint256& hash, const Blob& blob) { - ripple::TMIndexedObject& newObj = * (reply->add_objects ()); + protocol::TMIndexedObject& newObj = * (reply->add_objects ()); newObj.set_ledgerseq (ledgerSeq); newObj.set_hash (hash.begin (), 256 / 8); newObj.set_data (&blob[0], blob.size ()); } void NetworkOPs::makeFetchPack (Job&, boost::weak_ptr wPeer, - boost::shared_ptr request, + boost::shared_ptr request, Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime) { if (UptimeTimer::getInstance ().getElapsedSeconds () > (uUptime + 1)) @@ -2162,20 +2162,20 @@ void NetworkOPs::makeFetchPack (Job&, boost::weak_ptr wPeer, if (!peer) return; - ripple::TMGetObjectByHash reply; + protocol::TMGetObjectByHash reply; reply.set_query (false); if (request->has_seq ()) reply.set_seq (request->seq ()); reply.set_ledgerhash (request->ledgerhash ()); - reply.set_type (ripple::TMGetObjectByHash::otFETCH_PACK); + reply.set_type (protocol::TMGetObjectByHash::otFETCH_PACK); do { uint32 lSeq = wantLedger->getLedgerSeq (); - ripple::TMIndexedObject& newObj = *reply.add_objects (); + protocol::TMIndexedObject& newObj = *reply.add_objects (); newObj.set_hash (wantLedger->getHash ().begin (), 256 / 8); Serializer s (256); s.add32 (HashPrefix::ledgerMaster); @@ -2199,7 +2199,7 @@ void NetworkOPs::makeFetchPack (Job&, boost::weak_ptr wPeer, while (wantLedger && (UptimeTimer::getInstance ().getElapsedSeconds () <= (uUptime + 1))); WriteLog (lsINFO, NetworkOPs) << "Built fetch pack with " << reply.objects ().size () << " nodes"; - PackedMessage::pointer msg = boost::make_shared (reply, ripple::mtGET_OBJECTS); + PackedMessage::pointer msg = boost::make_shared (reply, protocol::mtGET_OBJECTS); peer->sendPacket (msg, false); } catch (...) diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index 5b0e0e211d..ef2532ec9a 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -206,17 +206,17 @@ public: Blob const& myNode, std::list< Blob >& newNodes); // ledger proposal/close functions - void processTrustedProposal (LedgerProposal::pointer proposal, boost::shared_ptr set, + void processTrustedProposal (LedgerProposal::pointer proposal, boost::shared_ptr set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood); SHAMapAddNode gotTXData (const boost::shared_ptr& peer, uint256 const& hash, const std::list& nodeIDs, const std::list< Blob >& nodeData); bool recvValidation (SerializedValidation::ref val, const std::string& source); void takePosition (int seq, SHAMap::ref position); SHAMap::pointer getTXMap (uint256 const& hash); - bool hasTXSet (const boost::shared_ptr& peer, uint256 const& set, ripple::TxSetStatus status); + bool hasTXSet (const boost::shared_ptr& peer, uint256 const& set, protocol::TxSetStatus status); void mapComplete (uint256 const& hash, SHAMap::ref map); bool stillNeedTXSet (uint256 const& hash); - void makeFetchPack (Job&, boost::weak_ptr peer, boost::shared_ptr request, + void makeFetchPack (Job&, boost::weak_ptr peer, boost::shared_ptr request, Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime); bool shouldFetchPack (uint32 seq); void gotFetchPack (bool progress, uint32 seq); diff --git a/src/cpp/ripple/ripple.proto b/src/cpp/ripple/ripple.proto index fac4080e34..37390d8e9b 100644 --- a/src/cpp/ripple/ripple.proto +++ b/src/cpp/ripple/ripple.proto @@ -1,6 +1,6 @@ // VFALCO TODO Rename the protobuf namespace from ripple to 'wire' or something // -package ripple; +package protocol; enum MessageType { diff --git a/src/cpp/ripple/ripple_InboundLedger.cpp b/src/cpp/ripple/ripple_InboundLedger.cpp index 506ac24158..0fa7b0cc5d 100644 --- a/src/cpp/ripple/ripple_InboundLedger.cpp +++ b/src/cpp/ripple/ripple_InboundLedger.cpp @@ -317,12 +317,12 @@ void InboundLedger::trigger (Peer::ref peer) } } - ripple::TMGetLedger tmGL; + protocol::TMGetLedger tmGL; tmGL.set_ledgerhash (mHash.begin (), mHash.size ()); if (getTimeouts () != 0) { - tmGL.set_querytype (ripple::qtINDIRECT); + tmGL.set_querytype (protocol::qtINDIRECT); if (!isProgress () && !mFailed && mByHash && (getTimeouts () > LEDGER_TIMEOUT_AGGRESSIVE)) { @@ -330,7 +330,7 @@ void InboundLedger::trigger (Peer::ref peer) if (!need.empty ()) { - ripple::TMGetObjectByHash tmBH; + protocol::TMGetObjectByHash tmBH; tmBH.set_query (true); tmBH.set_ledgerhash (mHash.begin (), mHash.size ()); bool typeSet = false; @@ -346,11 +346,11 @@ void InboundLedger::trigger (Peer::ref peer) if (p.first == tmBH.type ()) { - ripple::TMIndexedObject* io = tmBH.add_objects (); + protocol::TMIndexedObject* io = tmBH.add_objects (); io->set_hash (p.second.begin (), p.second.size ()); } } - PackedMessage::pointer packet = boost::make_shared (tmBH, ripple::mtGET_OBJECTS); + PackedMessage::pointer packet = boost::make_shared (tmBH, protocol::mtGET_OBJECTS); { boost::recursive_mutex::scoped_lock sl (mLock); @@ -381,7 +381,7 @@ void InboundLedger::trigger (Peer::ref peer) if (!mHaveBase && !mFailed) { - tmGL.set_itype (ripple::liBASE); + tmGL.set_itype (protocol::liBASE); WriteLog (lsTRACE, InboundLedger) << "Sending base request to " << (peer ? "selected peer" : "all peers"); sendRequest (tmGL, peer); return; @@ -397,7 +397,7 @@ void InboundLedger::trigger (Peer::ref peer) if (mLedger->peekTransactionMap ()->getHash ().isZero ()) { // we need the root node - tmGL.set_itype (ripple::liTX_NODE); + tmGL.set_itype (protocol::liTX_NODE); * (tmGL.add_nodeids ()) = SHAMapNode ().getRawString (); WriteLog (lsTRACE, InboundLedger) << "Sending TX root request to " << (peer ? "selected peer" : "all peers"); sendRequest (tmGL, peer); @@ -430,7 +430,7 @@ void InboundLedger::trigger (Peer::ref peer) if (!nodeIDs.empty ()) { - tmGL.set_itype (ripple::liTX_NODE); + tmGL.set_itype (protocol::liTX_NODE); BOOST_FOREACH (SHAMapNode & it, nodeIDs) { * (tmGL.add_nodeids ()) = it.getRawString (); @@ -450,7 +450,7 @@ void InboundLedger::trigger (Peer::ref peer) if (mLedger->peekAccountStateMap ()->getHash ().isZero ()) { // we need the root node - tmGL.set_itype (ripple::liAS_NODE); + tmGL.set_itype (protocol::liAS_NODE); * (tmGL.add_nodeids ()) = SHAMapNode ().getRawString (); WriteLog (lsTRACE, InboundLedger) << "Sending AS root request to " << (peer ? "selected peer" : "all peers"); sendRequest (tmGL, peer); @@ -483,7 +483,7 @@ void InboundLedger::trigger (Peer::ref peer) if (!nodeIDs.empty ()) { - tmGL.set_itype (ripple::liAS_NODE); + tmGL.set_itype (protocol::liAS_NODE); BOOST_FOREACH (SHAMapNode & it, nodeIDs) * (tmGL.add_nodeids ()) = it.getRawString (); WriteLog (lsTRACE, InboundLedger) << "Sending AS node " << nodeIDs.size () @@ -506,22 +506,22 @@ void InboundLedger::trigger (Peer::ref peer) } } -void PeerSet::sendRequest (const ripple::TMGetLedger& tmGL, Peer::ref peer) +void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL, Peer::ref peer) { if (!peer) sendRequest (tmGL); else - peer->sendPacket (boost::make_shared (tmGL, ripple::mtGET_LEDGER), false); + peer->sendPacket (boost::make_shared (tmGL, protocol::mtGET_LEDGER), false); } -void PeerSet::sendRequest (const ripple::TMGetLedger& tmGL) +void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL) { boost::recursive_mutex::scoped_lock sl (mLock); if (mPeers.empty ()) return; - PackedMessage::pointer packet = boost::make_shared (tmGL, ripple::mtGET_LEDGER); + PackedMessage::pointer packet = boost::make_shared (tmGL, protocol::mtGET_LEDGER); for (boost::unordered_map::iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it) { @@ -805,7 +805,7 @@ std::vector InboundLedger::getNeededHashes () if (!mHaveBase) { - ret.push_back (std::make_pair (ripple::TMGetObjectByHash::otLEDGER, mHash)); + ret.push_back (std::make_pair (protocol::TMGetObjectByHash::otLEDGER, mHash)); return ret; } @@ -814,7 +814,7 @@ std::vector InboundLedger::getNeededHashes () AccountStateSF filter (mLedger->getLedgerSeq ()); std::vector v = mLedger->getNeededAccountStateHashes (4, &filter); BOOST_FOREACH (uint256 const & h, v) - ret.push_back (std::make_pair (ripple::TMGetObjectByHash::otSTATE_NODE, h)); + ret.push_back (std::make_pair (protocol::TMGetObjectByHash::otSTATE_NODE, h)); } if (!mHaveTransactions) @@ -822,7 +822,7 @@ std::vector InboundLedger::getNeededHashes () TransactionStateSF filter (mLedger->getLedgerSeq ()); std::vector v = mLedger->getNeededAccountStateHashes (4, &filter); BOOST_FOREACH (uint256 const & h, v) - ret.push_back (std::make_pair (ripple::TMGetObjectByHash::otTRANSACTION_NODE, h)); + ret.push_back (std::make_pair (protocol::TMGetObjectByHash::otTRANSACTION_NODE, h)); } return ret; diff --git a/src/cpp/ripple/ripple_InboundLedger.h b/src/cpp/ripple/ripple_InboundLedger.h index fe1f44b88d..e712581459 100644 --- a/src/cpp/ripple/ripple_InboundLedger.h +++ b/src/cpp/ripple/ripple_InboundLedger.h @@ -79,7 +79,7 @@ public: void noAwaitData (); void checkLocal (); - typedef std::pair neededHash_t; + typedef std::pair neededHash_t; std::vector getNeededHashes (); diff --git a/src/cpp/ripple/ripple_InboundLedgers.cpp b/src/cpp/ripple/ripple_InboundLedgers.cpp index 6873b1e9d1..8fe09abbf6 100644 --- a/src/cpp/ripple/ripple_InboundLedgers.cpp +++ b/src/cpp/ripple/ripple_InboundLedgers.cpp @@ -76,9 +76,9 @@ bool InboundLedgers::awaitLedgerData (uint256 const& ledgerHash) } void InboundLedgers::gotLedgerData (Job&, uint256 hash, - boost::shared_ptr packet_ptr, boost::weak_ptr wPeer) + boost::shared_ptr packet_ptr, boost::weak_ptr wPeer) { - ripple::TMLedgerData& packet = *packet_ptr; + protocol::TMLedgerData& packet = *packet_ptr; Peer::pointer peer = wPeer.lock (); WriteLog (lsTRACE, InboundLedger) << "Got data (" << packet.nodes ().size () << ") for acquiring ledger: " << hash; @@ -100,7 +100,7 @@ void InboundLedgers::gotLedgerData (Job&, uint256 hash, if (!peer) return; - if (packet.type () == ripple::liBASE) + if (packet.type () == protocol::liBASE) { if (packet.nodes_size () < 1) { @@ -139,7 +139,7 @@ void InboundLedgers::gotLedgerData (Job&, uint256 hash, return; } - if ((packet.type () == ripple::liTX_NODE) || (packet.type () == ripple::liAS_NODE)) + if ((packet.type () == protocol::liTX_NODE) || (packet.type () == protocol::liAS_NODE)) { std::list nodeIDs; std::list< Blob > nodeData; @@ -153,7 +153,7 @@ void InboundLedgers::gotLedgerData (Job&, uint256 hash, for (int i = 0; i < packet.nodes ().size (); ++i) { - const ripple::TMLedgerNode& node = packet.nodes (i); + const protocol::TMLedgerNode& node = packet.nodes (i); if (!node.has_nodeid () || !node.has_nodedata ()) { @@ -168,7 +168,7 @@ void InboundLedgers::gotLedgerData (Job&, uint256 hash, SHAMapAddNode ret; - if (packet.type () == ripple::liTX_NODE) + if (packet.type () == protocol::liTX_NODE) ledger->takeTxNode (nodeIDs, nodeData, ret); else ledger->takeAsNode (nodeIDs, nodeData, ret); diff --git a/src/cpp/ripple/ripple_InboundLedgers.h b/src/cpp/ripple/ripple_InboundLedgers.h index 0006af1dc6..694fb5db6c 100644 --- a/src/cpp/ripple/ripple_InboundLedgers.h +++ b/src/cpp/ripple/ripple_InboundLedgers.h @@ -41,7 +41,7 @@ public: // void gotLedgerData (Job&, LedgerHash hash, - boost::shared_ptr packet, + boost::shared_ptr packet, boost::weak_ptr peer); int getFetchCount (int& timeoutCount); diff --git a/src/cpp/ripple/ripple_LedgerConsensus.cpp b/src/cpp/ripple/ripple_LedgerConsensus.cpp index d01ab5eaab..353cbbb309 100644 --- a/src/cpp/ripple/ripple_LedgerConsensus.cpp +++ b/src/cpp/ripple/ripple_LedgerConsensus.cpp @@ -82,11 +82,11 @@ void LedgerConsensus::checkOurValidation () theApp->getHashRouter ().addSuppression (signingHash); theApp->getValidations ().addValidation (v, "localMissing"); Blob validation = v->getSigned (); - ripple::TMValidation val; + protocol::TMValidation val; val.set_validation (&validation[0], validation.size ()); #if 0 theApp->getPeers ().relayMessage (NULL, - boost::make_shared (val, ripple::mtVALIDATION)); + boost::make_shared (val, protocol::mtVALIDATION)); #endif theApp->getOPs ().setLastValidation (v); WriteLog (lsWARNING, LedgerConsensus) << "Sending partial validation"; @@ -378,10 +378,10 @@ void LedgerConsensus::mapComplete (uint256 const& hash, SHAMap::ref map, bool ac void LedgerConsensus::sendHaveTxSet (uint256 const& hash, bool direct) { - ripple::TMHaveTransactionSet msg; + protocol::TMHaveTransactionSet msg; msg.set_hash (hash.begin (), 256 / 8); - msg.set_status (direct ? ripple::tsHAVE : ripple::tsCAN_GET); - PackedMessage::pointer packet = boost::make_shared (msg, ripple::mtHAVE_SET); + msg.set_status (direct ? protocol::tsHAVE : protocol::tsCAN_GET); + PackedMessage::pointer packet = boost::make_shared (msg, protocol::mtHAVE_SET); theApp->getPeers ().relayMessage (NULL, packet); } @@ -396,13 +396,13 @@ void LedgerConsensus::adjustCount (SHAMap::ref map, const std::vector& } } -void LedgerConsensus::statusChange (ripple::NodeEvent event, Ledger& ledger) +void LedgerConsensus::statusChange (protocol::NodeEvent event, Ledger& ledger) { // Send a node status change message to our peers - ripple::TMStatusChange s; + protocol::TMStatusChange s; if (!mHaveCorrectLCL) - s.set_newevent (ripple::neLOST_SYNC); + s.set_newevent (protocol::neLOST_SYNC); else s.set_newevent (event); @@ -418,7 +418,7 @@ void LedgerConsensus::statusChange (ripple::NodeEvent event, Ledger& ledger) s.set_firstseq (uMin); s.set_lastseq (uMax); - PackedMessage::pointer packet = boost::make_shared (s, ripple::mtSTATUS_CHANGE); + PackedMessage::pointer packet = boost::make_shared (s, protocol::mtSTATUS_CHANGE); theApp->getPeers ().relayMessage (NULL, packet); WriteLog (lsTRACE, LedgerConsensus) << "send status change to peer"; } @@ -468,7 +468,7 @@ void LedgerConsensus::closeLedger () mConsensusStartTime = boost::posix_time::microsec_clock::universal_time (); mCloseTime = theApp->getOPs ().getCloseTimeNC (); theApp->getOPs ().setLastCloseTime (mCloseTime); - statusChange (ripple::neCLOSING_LEDGER, *mPreviousLedger); + statusChange (protocol::neCLOSING_LEDGER, *mPreviousLedger); takeInitialPosition (*theApp->getLedgerMaster ().closeLedger (true)); } @@ -803,7 +803,7 @@ void LedgerConsensus::propose () { WriteLog (lsTRACE, LedgerConsensus) << "We propose: " << (mOurPosition->isBowOut () ? std::string ("bowOut") : mOurPosition->getCurrentHash ().GetHex ()); - ripple::TMProposeSet prop; + protocol::TMProposeSet prop; prop.set_currenttxhash (mOurPosition->getCurrentHash ().begin (), 256 / 8); prop.set_previousledger (mOurPosition->getPrevLedger ().begin (), 256 / 8); @@ -815,7 +815,7 @@ void LedgerConsensus::propose () prop.set_nodepubkey (&pubKey[0], pubKey.size ()); prop.set_signature (&sig[0], sig.size ()); theApp->getPeers ().relayMessage (NULL, - boost::make_shared (prop, ripple::mtPROPOSE_LEDGER)); + boost::make_shared (prop, protocol::mtPROPOSE_LEDGER)); } void LedgerConsensus::addDisputedTransaction (uint256 const& txID, Blob const& tx) @@ -851,11 +851,11 @@ void LedgerConsensus::addDisputedTransaction (uint256 const& txID, Blob const& t if (theApp->getHashRouter ().setFlag (txID, SF_RELAYED)) { - ripple::TMTransaction msg; + protocol::TMTransaction msg; msg.set_rawtransaction (& (tx.front ()), tx.size ()); - msg.set_status (ripple::tsNEW); + msg.set_status (protocol::tsNEW); msg.set_receivetimestamp (theApp->getOPs ().getNetworkTimeNC ()); - PackedMessage::pointer packet = boost::make_shared (msg, ripple::mtTRANSACTION); + PackedMessage::pointer packet = boost::make_shared (msg, protocol::mtTRANSACTION); theApp->getPeers ().relayMessage (NULL, packet); } } @@ -919,9 +919,9 @@ bool LedgerConsensus::peerPosition (LedgerProposal::ref newPosition) return true; } -bool LedgerConsensus::peerHasSet (Peer::ref peer, uint256 const& hashSet, ripple::TxSetStatus status) +bool LedgerConsensus::peerHasSet (Peer::ref peer, uint256 const& hashSet, protocol::TxSetStatus status) { - if (status != ripple::tsHAVE) // Indirect requests are for future support + if (status != protocol::tsHAVE) // Indirect requests are for future support return true; std::vector< boost::weak_ptr >& set = mPeerData[hashSet]; @@ -1015,14 +1015,14 @@ void LedgerConsensus::playbackProposals () if (relay && theApp->getHashRouter ().swapSet (proposal.getSuppress (), set, SF_RELAYED)) { WriteLog (lsDEBUG, LedgerConsensus) << "Stored proposal delayed relay"; - ripple::TMProposeSet set; + protocol::TMProposeSet set; set.set_proposeseq set.set_currenttxhash (, 256 / 8); previousledger closetime nodepubkey signature - PackedMessage::pointer message = boost::make_shared (set, ripple::mtPROPOSE_LEDGER); + PackedMessage::pointer message = boost::make_shared (set, protocol::mtPROPOSE_LEDGER); theApp->getPeers ().relayMessageBut (peers, message); } @@ -1241,7 +1241,7 @@ void LedgerConsensus::accept (SHAMap::ref set, LoadEvent::pointer) WriteLog (lsTRACE, LedgerConsensus) << p; } - statusChange (ripple::neACCEPTED_LEDGER, *newLCL); + statusChange (protocol::neACCEPTED_LEDGER, *newLCL); if (mValidating && !mConsensusFail) { @@ -1262,10 +1262,10 @@ void LedgerConsensus::accept (SHAMap::ref set, LoadEvent::pointer) theApp->getValidations ().addValidation (v, "local"); theApp->getOPs ().setLastValidation (v); Blob validation = v->getSigned (); - ripple::TMValidation val; + protocol::TMValidation val; val.set_validation (&validation[0], validation.size ()); int j = theApp->getPeers ().relayMessage (NULL, - boost::make_shared (val, ripple::mtVALIDATION)); + boost::make_shared (val, protocol::mtVALIDATION)); WriteLog (lsINFO, LedgerConsensus) << "CNF Val " << newLCLHash << " to " << j << " peers"; } else diff --git a/src/cpp/ripple/ripple_LedgerConsensus.h b/src/cpp/ripple/ripple_LedgerConsensus.h index 892de3602a..da0d1ec93d 100644 --- a/src/cpp/ripple/ripple_LedgerConsensus.h +++ b/src/cpp/ripple/ripple_LedgerConsensus.h @@ -58,7 +58,7 @@ public: bool peerPosition (LedgerProposal::ref); - bool peerHasSet (Peer::ref peer, uint256 const & set, ripple::TxSetStatus status); + bool peerHasSet (Peer::ref peer, uint256 const & set, protocol::TxSetStatus status); SHAMapAddNode peerGaveNodes (Peer::ref peer, uint256 const & setHash, const std::list& nodeIDs, const std::list< Blob >& nodeData); @@ -95,7 +95,7 @@ private: uint32 roundCloseTime (uint32 closeTime); // manipulating our own position - void statusChange (ripple::NodeEvent, Ledger & ledger); + void statusChange (protocol::NodeEvent, Ledger & ledger); void takeInitialPosition (Ledger & initialLedger); void updateOurPositions (); void playbackProposals (); diff --git a/src/cpp/ripple/ripple_Peer.cpp b/src/cpp/ripple/ripple_Peer.cpp index 0ce93504a7..f4fdde0505 100644 --- a/src/cpp/ripple/ripple_Peer.cpp +++ b/src/cpp/ripple/ripple_Peer.cpp @@ -139,8 +139,8 @@ private: std::vector mReadbuf; std::list mSendQ; PackedMessage::pointer mSendingPacket; - ripple::TMStatusChange mLastStatus; - ripple::TMHello mHello; + protocol::TMStatusChange mLastStatus; + protocol::TMHello mHello; private: void handleShutdown (const boost::system::error_code & error) @@ -163,33 +163,33 @@ private: void sendHello (); - void recvHello (ripple::TMHello & packet); - void recvTransaction (ripple::TMTransaction & packet, ScopedLock & MasterLockHolder); - void recvValidation (const boost::shared_ptr& packet, ScopedLock & MasterLockHolder); - void recvGetValidation (ripple::TMGetValidations & packet); - void recvContact (ripple::TMContact & packet); - void recvGetContacts (ripple::TMGetContacts & packet); - void recvGetPeers (ripple::TMGetPeers & packet, ScopedLock & MasterLockHolder); - void recvPeers (ripple::TMPeers & packet); - void recvGetObjectByHash (const boost::shared_ptr& packet); - void recvPing (ripple::TMPing & packet); - void recvErrorMessage (ripple::TMErrorMsg & packet); - void recvSearchTransaction (ripple::TMSearchTransaction & packet); - void recvGetAccount (ripple::TMGetAccount & packet); - void recvAccount (ripple::TMAccount & packet); - void recvGetLedger (ripple::TMGetLedger & packet, ScopedLock & MasterLockHolder); - void recvLedger (const boost::shared_ptr& packet, ScopedLock & MasterLockHolder); - void recvStatus (ripple::TMStatusChange & packet); - void recvPropose (const boost::shared_ptr& packet); - void recvHaveTxSet (ripple::TMHaveTransactionSet & packet); - void recvProofWork (ripple::TMProofWork & packet); + void recvHello (protocol::TMHello & packet); + void recvTransaction (protocol::TMTransaction & packet, ScopedLock & MasterLockHolder); + void recvValidation (const boost::shared_ptr& packet, ScopedLock & MasterLockHolder); + void recvGetValidation (protocol::TMGetValidations & packet); + void recvContact (protocol::TMContact & packet); + void recvGetContacts (protocol::TMGetContacts & packet); + void recvGetPeers (protocol::TMGetPeers & packet, ScopedLock & MasterLockHolder); + void recvPeers (protocol::TMPeers & packet); + void recvGetObjectByHash (const boost::shared_ptr& packet); + void recvPing (protocol::TMPing & packet); + void recvErrorMessage (protocol::TMErrorMsg & packet); + void recvSearchTransaction (protocol::TMSearchTransaction & packet); + void recvGetAccount (protocol::TMGetAccount & packet); + void recvAccount (protocol::TMAccount & packet); + void recvGetLedger (protocol::TMGetLedger & packet, ScopedLock & MasterLockHolder); + void recvLedger (const boost::shared_ptr& packet, ScopedLock & MasterLockHolder); + void recvStatus (protocol::TMStatusChange & packet); + void recvPropose (const boost::shared_ptr& packet); + void recvHaveTxSet (protocol::TMHaveTransactionSet & packet); + void recvProofWork (protocol::TMProofWork & packet); void getSessionCookie (std::string & strDst); void addLedger (uint256 const & ledger); void addTxSet (uint256 const & TxSet); - void doFetchPack (const boost::shared_ptr& packet); + void doFetchPack (const boost::shared_ptr& packet); // VFALCO NOTE why is this a static member instead of a regular member? static void doProofOfWork (Job&, boost::weak_ptr , ProofOfWork::pointer); @@ -325,9 +325,9 @@ void PeerImp::handlePingTimer (const boost::system::error_code& ecResult) { // idle->pingsent mActive = 1; - ripple::TMPing packet; - packet.set_type (ripple::TMPing::ptPING); - sendPacket (boost::make_shared (packet, ripple::mtPING), true); + protocol::TMPing packet; + packet.set_type (protocol::TMPing::ptPING); + sendPacket (boost::make_shared (packet, protocol::mtPING), true); } else // active->idle mActive = 0; @@ -650,7 +650,7 @@ void PeerImp::processReadBuffer () ScopedLock sl (theApp->getMasterLock ()); // If connected and get a mtHELLO or if not connected and get a non-mtHELLO, wrong message was sent. - if (mHelloed == (type == ripple::mtHELLO)) + if (mHelloed == (type == protocol::mtHELLO)) { WriteLog (lsWARNING, Peer) << "Wrong message type: " << type; detach ("prb1", true); @@ -659,10 +659,10 @@ void PeerImp::processReadBuffer () { switch (type) { - case ripple::mtHELLO: + case protocol::mtHELLO: { event->reName ("PeerImp::hello"); - ripple::TMHello msg; + protocol::TMHello msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvHello (msg); @@ -671,10 +671,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtERROR_MSG: + case protocol::mtERROR_MSG: { event->reName ("PeerImp::errormessage"); - ripple::TMErrorMsg msg; + protocol::TMErrorMsg msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvErrorMessage (msg); @@ -683,10 +683,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtPING: + case protocol::mtPING: { event->reName ("PeerImp::ping"); - ripple::TMPing msg; + protocol::TMPing msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvPing (msg); @@ -695,10 +695,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtGET_CONTACTS: + case protocol::mtGET_CONTACTS: { event->reName ("PeerImp::getcontacts"); - ripple::TMGetContacts msg; + protocol::TMGetContacts msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvGetContacts (msg); @@ -707,10 +707,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtCONTACT: + case protocol::mtCONTACT: { event->reName ("PeerImp::contact"); - ripple::TMContact msg; + protocol::TMContact msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvContact (msg); @@ -719,10 +719,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtGET_PEERS: + case protocol::mtGET_PEERS: { event->reName ("PeerImp::getpeers"); - ripple::TMGetPeers msg; + protocol::TMGetPeers msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvGetPeers (msg, sl); @@ -731,10 +731,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtPEERS: + case protocol::mtPEERS: { event->reName ("PeerImp::peers"); - ripple::TMPeers msg; + protocol::TMPeers msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvPeers (msg); @@ -743,10 +743,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtSEARCH_TRANSACTION: + case protocol::mtSEARCH_TRANSACTION: { event->reName ("PeerImp::searchtransaction"); - ripple::TMSearchTransaction msg; + protocol::TMSearchTransaction msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvSearchTransaction (msg); @@ -755,10 +755,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtGET_ACCOUNT: + case protocol::mtGET_ACCOUNT: { event->reName ("PeerImp::getaccount"); - ripple::TMGetAccount msg; + protocol::TMGetAccount msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvGetAccount (msg); @@ -767,10 +767,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtACCOUNT: + case protocol::mtACCOUNT: { event->reName ("PeerImp::account"); - ripple::TMAccount msg; + protocol::TMAccount msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvAccount (msg); @@ -779,10 +779,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtTRANSACTION: + case protocol::mtTRANSACTION: { event->reName ("PeerImp::transaction"); - ripple::TMTransaction msg; + protocol::TMTransaction msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvTransaction (msg, sl); @@ -791,10 +791,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtSTATUS_CHANGE: + case protocol::mtSTATUS_CHANGE: { event->reName ("PeerImp::statuschange"); - ripple::TMStatusChange msg; + protocol::TMStatusChange msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvStatus (msg); @@ -803,10 +803,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtPROPOSE_LEDGER: + case protocol::mtPROPOSE_LEDGER: { event->reName ("PeerImp::propose"); - boost::shared_ptr msg = boost::make_shared (); + boost::shared_ptr msg = boost::make_shared (); if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvPropose (msg); @@ -815,10 +815,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtGET_LEDGER: + case protocol::mtGET_LEDGER: { event->reName ("PeerImp::getledger"); - ripple::TMGetLedger msg; + protocol::TMGetLedger msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvGetLedger (msg, sl); @@ -827,10 +827,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtLEDGER_DATA: + case protocol::mtLEDGER_DATA: { event->reName ("PeerImp::ledgerdata"); - boost::shared_ptr msg = boost::make_shared (); + boost::shared_ptr msg = boost::make_shared (); if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvLedger (msg, sl); @@ -839,10 +839,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtHAVE_SET: + case protocol::mtHAVE_SET: { event->reName ("PeerImp::haveset"); - ripple::TMHaveTransactionSet msg; + protocol::TMHaveTransactionSet msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvHaveTxSet (msg); @@ -851,10 +851,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtVALIDATION: + case protocol::mtVALIDATION: { event->reName ("PeerImp::validation"); - boost::shared_ptr msg = boost::make_shared (); + boost::shared_ptr msg = boost::make_shared (); if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvValidation (msg, sl); @@ -864,9 +864,9 @@ void PeerImp::processReadBuffer () break; #if 0 - case ripple::mtGET_VALIDATION: + case protocol::mtGET_VALIDATION: { - ripple::TM msg; + protocol::TM msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recv (msg); @@ -877,10 +877,10 @@ void PeerImp::processReadBuffer () #endif - case ripple::mtGET_OBJECTS: + case protocol::mtGET_OBJECTS: { event->reName ("PeerImp::getobjects"); - boost::shared_ptr msg = boost::make_shared (); + boost::shared_ptr msg = boost::make_shared (); if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvGetObjectByHash (msg); @@ -889,10 +889,10 @@ void PeerImp::processReadBuffer () } break; - case ripple::mtPROOFOFWORK: + case protocol::mtPROOFOFWORK: { event->reName ("PeerImp::proofofwork"); - ripple::TMProofWork msg; + protocol::TMProofWork msg; if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes)) recvProofWork (msg); @@ -910,7 +910,7 @@ void PeerImp::processReadBuffer () } } -void PeerImp::recvHello (ripple::TMHello& packet) +void PeerImp::recvHello (protocol::TMHello& packet) { bool bDetach = true; @@ -1094,7 +1094,7 @@ static void checkTransaction (Job&, int flags, SerializedTransaction::pointer st #endif } -void PeerImp::recvTransaction (ripple::TMTransaction& packet, ScopedLock& MasterLockHolder) +void PeerImp::recvTransaction (protocol::TMTransaction& packet, ScopedLock& MasterLockHolder) { MasterLockHolder.unlock (); Transaction::pointer tx; @@ -1147,7 +1147,7 @@ void PeerImp::recvTransaction (ripple::TMTransaction& packet, ScopedLock& Master } // Called from our JobQueue -static void checkPropose (Job& job, boost::shared_ptr packet, +static void checkPropose (Job& job, boost::shared_ptr packet, LedgerProposal::pointer proposal, uint256 consensusLCL, RippleAddress nodePublic, boost::weak_ptr peer) { bool sigGood = false; @@ -1156,7 +1156,7 @@ static void checkPropose (Job& job, boost::shared_ptr pack WriteLog (lsTRACE, Peer) << "Checking " << (isTrusted ? "trusted" : "UNtrusted") << " proposal"; assert (packet); - ripple::TMProposeSet& set = *packet; + protocol::TMProposeSet& set = *packet; uint256 prevLedger; @@ -1199,17 +1199,17 @@ static void checkPropose (Job& job, boost::shared_ptr pack WriteLog (lsTRACE, Peer) << "relaying untrusted proposal"; std::set peers; theApp->getHashRouter ().swapSet (proposal->getHashRouter (), peers, SF_RELAYED); - PackedMessage::pointer message = boost::make_shared (set, ripple::mtPROPOSE_LEDGER); + PackedMessage::pointer message = boost::make_shared (set, protocol::mtPROPOSE_LEDGER); theApp->getPeers ().relayMessageBut (peers, message); } else WriteLog (lsDEBUG, Peer) << "Not relaying untrusted proposal"; } -void PeerImp::recvPropose (const boost::shared_ptr& packet) +void PeerImp::recvPropose (const boost::shared_ptr& packet) { assert (packet); - ripple::TMProposeSet& set = *packet; + protocol::TMProposeSet& set = *packet; if ((set.currenttxhash ().size () != 32) || (set.nodepubkey ().size () < 28) || (set.signature ().size () < 56) || (set.nodepubkey ().size () > 128) || (set.signature ().size () > 128)) @@ -1277,7 +1277,7 @@ void PeerImp::recvPropose (const boost::shared_ptr& packet mNodePublic, boost::weak_ptr (shared_from_this ()))); } -void PeerImp::recvHaveTxSet (ripple::TMHaveTransactionSet& packet) +void PeerImp::recvHaveTxSet (protocol::TMHaveTransactionSet& packet) { uint256 hashes; @@ -1290,7 +1290,7 @@ void PeerImp::recvHaveTxSet (ripple::TMHaveTransactionSet& packet) uint256 hash; memcpy (hash.begin (), packet.hash ().data (), 32); - if (packet.status () == ripple::tsHAVE) + if (packet.status () == protocol::tsHAVE) addTxSet (hash); if (!theApp->getOPs ().hasTXSet (shared_from_this (), hash, packet.status ())) @@ -1298,7 +1298,7 @@ void PeerImp::recvHaveTxSet (ripple::TMHaveTransactionSet& packet) } static void checkValidation (Job&, SerializedValidation::pointer val, uint256 signingHash, - bool isTrusted, bool isCluster, boost::shared_ptr packet, boost::weak_ptr peer) + bool isTrusted, bool isCluster, boost::shared_ptr packet, boost::weak_ptr peer) { #ifndef TRUST_NETWORK @@ -1325,7 +1325,7 @@ static void checkValidation (Job&, SerializedValidation::pointer val, uint256 si if (theApp->getOPs ().recvValidation (val, source) && theApp->getHashRouter ().swapSet (signingHash, peers, SF_RELAYED)) { - PackedMessage::pointer message = boost::make_shared (*packet, ripple::mtVALIDATION); + PackedMessage::pointer message = boost::make_shared (*packet, protocol::mtVALIDATION); theApp->getPeers ().relayMessageBut (peers, message); } } @@ -1340,7 +1340,7 @@ static void checkValidation (Job&, SerializedValidation::pointer val, uint256 si #endif } -void PeerImp::recvValidation (const boost::shared_ptr& packet, ScopedLock& MasterLockHolder) +void PeerImp::recvValidation (const boost::shared_ptr& packet, ScopedLock& MasterLockHolder) { MasterLockHolder.unlock (); @@ -1387,22 +1387,22 @@ void PeerImp::recvValidation (const boost::shared_ptr& pac #endif } -void PeerImp::recvGetValidation (ripple::TMGetValidations& packet) +void PeerImp::recvGetValidation (protocol::TMGetValidations& packet) { } -void PeerImp::recvContact (ripple::TMContact& packet) +void PeerImp::recvContact (protocol::TMContact& packet) { } -void PeerImp::recvGetContacts (ripple::TMGetContacts& packet) +void PeerImp::recvGetContacts (protocol::TMGetContacts& packet) { } // Return a list of your favorite people // TODO: filter out all the LAN peers // TODO: filter out the peer you are talking to -void PeerImp::recvGetPeers (ripple::TMGetPeers& packet, ScopedLock& MasterLockHolder) +void PeerImp::recvGetPeers (protocol::TMGetPeers& packet, ScopedLock& MasterLockHolder) { MasterLockHolder.unlock (); std::vector addrs; @@ -1411,7 +1411,7 @@ void PeerImp::recvGetPeers (ripple::TMGetPeers& packet, ScopedLock& MasterLockHo if (!addrs.empty ()) { - ripple::TMPeers peers; + protocol::TMPeers peers; for (unsigned int n = 0; n < addrs.size (); n++) { @@ -1421,20 +1421,20 @@ void PeerImp::recvGetPeers (ripple::TMGetPeers& packet, ScopedLock& MasterLockHo splitIpPort (addrs[n], strIP, iPort); // XXX This should also ipv6 - ripple::TMIPv4EndPoint* addr = peers.add_nodes (); + protocol::TMIPv4EndPoint* addr = peers.add_nodes (); addr->set_ipv4 (inet_addr (strIP.c_str ())); addr->set_ipv4port (iPort); //WriteLog (lsINFO, Peer) << "Peer: Teaching: " << ADDRESS(this) << ": " << n << ": " << strIP << " " << iPort; } - PackedMessage::pointer message = boost::make_shared (peers, ripple::mtPEERS); + PackedMessage::pointer message = boost::make_shared (peers, protocol::mtPEERS); sendPacket (message, true); } } // TODO: filter out all the LAN peers -void PeerImp::recvPeers (ripple::TMPeers& packet) +void PeerImp::recvPeers (protocol::TMPeers& packet) { for (int i = 0; i < packet.nodes ().size (); ++i) { @@ -1454,20 +1454,20 @@ void PeerImp::recvPeers (ripple::TMPeers& packet) } } -void PeerImp::recvGetObjectByHash (const boost::shared_ptr& ptr) +void PeerImp::recvGetObjectByHash (const boost::shared_ptr& ptr) { - ripple::TMGetObjectByHash& packet = *ptr; + protocol::TMGetObjectByHash& packet = *ptr; if (packet.query ()) { // this is a query - if (packet.type () == ripple::TMGetObjectByHash::otFETCH_PACK) + if (packet.type () == protocol::TMGetObjectByHash::otFETCH_PACK) { doFetchPack (ptr); return; } - ripple::TMGetObjectByHash reply; + protocol::TMGetObjectByHash reply; reply.set_query (false); @@ -1483,7 +1483,7 @@ void PeerImp::recvGetObjectByHash (const boost::shared_ptrgetData ().front (), hObj->getData ().size ()); @@ -1507,7 +1507,7 @@ void PeerImp::recvGetObjectByHash (const boost::shared_ptr (reply, ripple::mtGET_OBJECTS), true); + sendPacket (boost::make_shared (reply, protocol::mtGET_OBJECTS), true); } else { @@ -1518,7 +1518,7 @@ void PeerImp::recvGetObjectByHash (const boost::shared_ptrgetOPs ().gotFetchPack (progress, pLSeq); } } -void PeerImp::recvPing (ripple::TMPing& packet) +void PeerImp::recvPing (protocol::TMPing& packet) { - if (packet.type () == ripple::TMPing::ptPING) + if (packet.type () == protocol::TMPing::ptPING) { - packet.set_type (ripple::TMPing::ptPONG); - sendPacket (boost::make_shared (packet, ripple::mtPING), true); + packet.set_type (protocol::TMPing::ptPONG); + sendPacket (boost::make_shared (packet, protocol::mtPING), true); } - else if (packet.type () == ripple::TMPing::ptPONG) + else if (packet.type () == protocol::TMPing::ptPONG) { mActive = 2; } } -void PeerImp::recvErrorMessage (ripple::TMErrorMsg& packet) +void PeerImp::recvErrorMessage (protocol::TMErrorMsg& packet) { } -void PeerImp::recvSearchTransaction (ripple::TMSearchTransaction& packet) +void PeerImp::recvSearchTransaction (protocol::TMSearchTransaction& packet) { } -void PeerImp::recvGetAccount (ripple::TMGetAccount& packet) +void PeerImp::recvGetAccount (protocol::TMGetAccount& packet) { } -void PeerImp::recvAccount (ripple::TMAccount& packet) +void PeerImp::recvAccount (protocol::TMAccount& packet) { } -void PeerImp::recvProofWork (ripple::TMProofWork& packet) +void PeerImp::recvProofWork (protocol::TMProofWork& packet) { if (packet.has_response ()) { @@ -1660,7 +1660,7 @@ void PeerImp::recvProofWork (ripple::TMProofWork& packet) WriteLog (lsINFO, Peer) << "Received in valid proof of work object from peer"; } -void PeerImp::recvStatus (ripple::TMStatusChange& packet) +void PeerImp::recvStatus (protocol::TMStatusChange& packet) { WriteLog (lsTRACE, Peer) << "Received status change from peer " << getIP (); @@ -1672,12 +1672,12 @@ void PeerImp::recvStatus (ripple::TMStatusChange& packet) else { // preserve old status - ripple::NodeStatus status = mLastStatus.newstatus (); + protocol::NodeStatus status = mLastStatus.newstatus (); mLastStatus = packet; packet.set_newstatus (status); } - if (packet.newevent () == ripple::neLOST_SYNC) + if (packet.newevent () == protocol::neLOST_SYNC) { if (!mClosedLedgerHash.isZero ()) { @@ -1716,10 +1716,10 @@ void PeerImp::recvStatus (ripple::TMStatusChange& packet) mMaxLedger = packet.lastseq (); } -void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLockHolder) +void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLockHolder) { SHAMap::pointer map; - ripple::TMLedgerData reply; + protocol::TMLedgerData reply; bool fatLeaves = true, fatRoot = false; if (packet.has_requestcookie ()) @@ -1727,7 +1727,7 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock std::string logMe; - if (packet.itype () == ripple::liTS_CANDIDATE) + if (packet.itype () == protocol::liTS_CANDIDATE) { // Request is for a transaction candidate set WriteLog (lsDEBUG, Peer) << "Received request for TX candidate set data " << getIP (); @@ -1764,7 +1764,7 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock Peer::ref selectedPeer = usablePeers[rand () % usablePeers.size ()]; packet.set_requestcookie (getPeerId ()); - selectedPeer->sendPacket (boost::make_shared (packet, ripple::mtGET_LEDGER), false); + selectedPeer->sendPacket (boost::make_shared (packet, protocol::mtGET_LEDGER), false); return; } @@ -1775,7 +1775,7 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock reply.set_ledgerseq (0); reply.set_ledgerhash (txHash.begin (), txHash.size ()); - reply.set_type (ripple::liTS_CANDIDATE); + reply.set_type (protocol::liTS_CANDIDATE); fatLeaves = false; // We'll already have most transactions fatRoot = true; // Save a pass } @@ -1826,7 +1826,7 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock Peer::ref selectedPeer = usablePeers[rand () % usablePeers.size ()]; packet.set_requestcookie (getPeerId ()); - selectedPeer->sendPacket (boost::make_shared (packet, ripple::mtGET_LEDGER), false); + selectedPeer->sendPacket (boost::make_shared (packet, protocol::mtGET_LEDGER), false); WriteLog (lsDEBUG, Peer) << "Ledger request routed"; return; } @@ -1836,9 +1836,9 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock ledger = theApp->getLedgerMaster ().getLedgerBySeq (packet.ledgerseq ()); CondLog (!ledger, lsDEBUG, Peer) << "Don't have ledger " << packet.ledgerseq (); } - else if (packet.has_ltype () && (packet.ltype () == ripple::ltCURRENT)) + else if (packet.has_ltype () && (packet.ltype () == protocol::ltCURRENT)) ledger = theApp->getLedgerMaster ().getCurrentLedger (); - else if (packet.has_ltype () && (packet.ltype () == ripple::ltCLOSED) ) + else if (packet.has_ltype () && (packet.ltype () == protocol::ltCLOSED) ) { ledger = theApp->getLedgerMaster ().getClosedLedger (); @@ -1878,7 +1878,7 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock reply.set_ledgerseq (ledger->getLedgerSeq ()); reply.set_type (packet.itype ()); - if (packet.itype () == ripple::liBASE) + if (packet.itype () == protocol::liBASE) { // they want the ledger base data WriteLog (lsTRACE, Peer) << "They want ledger base data"; @@ -1912,18 +1912,18 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock } } - PackedMessage::pointer oPacket = boost::make_shared (reply, ripple::mtLEDGER_DATA); + PackedMessage::pointer oPacket = boost::make_shared (reply, protocol::mtLEDGER_DATA); sendPacket (oPacket, true); return; } - if (packet.itype () == ripple::liTX_NODE) + if (packet.itype () == protocol::liTX_NODE) { map = ledger->peekTransactionMap (); logMe += " TX:"; logMe += map->getHash ().GetHex (); } - else if (packet.itype () == ripple::liAS_NODE) + else if (packet.itype () == protocol::liAS_NODE) { map = ledger->peekAccountStateMap (); logMe += " AS:"; @@ -1968,7 +1968,7 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock { Serializer nID (33); nodeIDIterator->addIDRaw (nID); - ripple::TMLedgerNode* node = reply.add_nodes (); + protocol::TMLedgerNode* node = reply.add_nodes (); node->set_nodeid (nID.getDataPtr (), nID.getLength ()); node->set_nodedata (&rawNodeIterator->front (), rawNodeIterator->size ()); } @@ -1980,13 +1980,13 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock { std::string info; - if (packet.itype () == ripple::liTS_CANDIDATE) + if (packet.itype () == protocol::liTS_CANDIDATE) info = "TS candidate"; - else if (packet.itype () == ripple::liBASE) + else if (packet.itype () == protocol::liBASE) info = "Ledger base"; - else if (packet.itype () == ripple::liTX_NODE) + else if (packet.itype () == protocol::liTX_NODE) info = "TX node"; - else if (packet.itype () == ripple::liAS_NODE) + else if (packet.itype () == protocol::liAS_NODE) info = "AS node"; if (!packet.has_ledgerhash ()) @@ -1996,14 +1996,14 @@ void PeerImp::recvGetLedger (ripple::TMGetLedger& packet, ScopedLock& MasterLock } } - PackedMessage::pointer oPacket = boost::make_shared (reply, ripple::mtLEDGER_DATA); + PackedMessage::pointer oPacket = boost::make_shared (reply, protocol::mtLEDGER_DATA); sendPacket (oPacket, true); } -void PeerImp::recvLedger (const boost::shared_ptr& packet_ptr, ScopedLock& MasterLockHolder) +void PeerImp::recvLedger (const boost::shared_ptr& packet_ptr, ScopedLock& MasterLockHolder) { MasterLockHolder.unlock (); - ripple::TMLedgerData& packet = *packet_ptr; + protocol::TMLedgerData& packet = *packet_ptr; if (packet.nodes ().size () <= 0) { @@ -2019,7 +2019,7 @@ void PeerImp::recvLedger (const boost::shared_ptr& packet_ if (target) { packet.clear_requestcookie (); - target->sendPacket (boost::make_shared (packet, ripple::mtLEDGER_DATA), false); + target->sendPacket (boost::make_shared (packet, protocol::mtLEDGER_DATA), false); } else { @@ -2041,7 +2041,7 @@ void PeerImp::recvLedger (const boost::shared_ptr& packet_ memcpy (hash.begin (), packet.ledgerhash ().data (), 32); - if (packet.type () == ripple::liTS_CANDIDATE) + if (packet.type () == protocol::liTS_CANDIDATE) { // got data for a candidate transaction set std::list nodeIDs; @@ -2049,7 +2049,7 @@ void PeerImp::recvLedger (const boost::shared_ptr& packet_ for (int i = 0; i < packet.nodes ().size (); ++i) { - const ripple::TMLedgerNode& node = packet.nodes (i); + const protocol::TMLedgerNode& node = packet.nodes (i); if (!node.has_nodeid () || !node.has_nodedata () || (node.nodeid ().size () != 33)) { @@ -2168,7 +2168,7 @@ void PeerImp::sendHello () theApp->getLocalCredentials ().getNodePrivate ().signNodePrivate (mCookieHash, vchSig); - ripple::TMHello h; + protocol::TMHello h; h.set_protoversion (MAKE_VERSION_INT (PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR)); h.set_protoversionmin (MAKE_VERSION_INT (MIN_PROTO_MAJOR, MIN_PROTO_MINOR)); @@ -2190,18 +2190,18 @@ void PeerImp::sendHello () h.set_ledgerprevious (hash.begin (), hash.GetSerializeSize ()); } - PackedMessage::pointer packet = boost::make_shared (h, ripple::mtHELLO); + PackedMessage::pointer packet = boost::make_shared (h, protocol::mtHELLO); sendPacket (packet, true); } void PeerImp::sendGetPeers () { // Ask peer for known other peers. - ripple::TMGetPeers getPeers; + protocol::TMGetPeers getPeers; getPeers.set_doweneedthis (1); - PackedMessage::pointer packet = boost::make_shared (getPeers, ripple::mtGET_PEERS); + PackedMessage::pointer packet = boost::make_shared (getPeers, protocol::mtGET_PEERS); sendPacket (packet, true); } @@ -2231,10 +2231,10 @@ void PeerImp::doProofOfWork (Job&, boost::weak_ptr peer, ProofOfWork::poi if (pptr) { - ripple::TMProofWork reply; + protocol::TMProofWork reply; reply.set_token (pow->getToken ()); reply.set_response (solution.begin (), solution.size ()); - pptr->sendPacket (boost::make_shared (reply, ripple::mtPROOFOFWORK), false); + pptr->sendPacket (boost::make_shared (reply, protocol::mtPROOFOFWORK), false); } else { @@ -2243,7 +2243,7 @@ void PeerImp::doProofOfWork (Job&, boost::weak_ptr peer, ProofOfWork::poi } } -void PeerImp::doFetchPack (const boost::shared_ptr& packet) +void PeerImp::doFetchPack (const boost::shared_ptr& packet) { if (theApp->getFeeTrack ().isLoaded ()) { @@ -2332,23 +2332,23 @@ Json::Value PeerImp::getJson () { switch (mLastStatus.newstatus ()) { - case ripple::nsCONNECTING: + case protocol::nsCONNECTING: ret["status"] = "connecting"; break; - case ripple::nsCONNECTED: + case protocol::nsCONNECTED: ret["status"] = "connected"; break; - case ripple::nsMONITORING: + case protocol::nsMONITORING: ret["status"] = "monitoring"; break; - case ripple::nsVALIDATING: + case protocol::nsVALIDATING: ret["status"] = "validating"; break; - case ripple::nsSHUTTING: + case protocol::nsSHUTTING: ret["status"] = "shutting"; break; diff --git a/src/cpp/ripple/ripple_PeerSet.h b/src/cpp/ripple/ripple_PeerSet.h index e7c60083cb..7e319610d8 100644 --- a/src/cpp/ripple/ripple_PeerSet.h +++ b/src/cpp/ripple/ripple_PeerSet.h @@ -84,8 +84,8 @@ protected: } void invokeOnTimer (); - void sendRequest (const ripple::TMGetLedger& message); - void sendRequest (const ripple::TMGetLedger& message, Peer::ref peer); + void sendRequest (const protocol::TMGetLedger& message); + void sendRequest (const protocol::TMGetLedger& message, Peer::ref peer); protected: uint256 mHash; diff --git a/src/cpp/ripple/ripple_TransactionAcquire.cpp b/src/cpp/ripple/ripple_TransactionAcquire.cpp index 0d5c58184b..5a072eaa41 100644 --- a/src/cpp/ripple/ripple_TransactionAcquire.cpp +++ b/src/cpp/ripple/ripple_TransactionAcquire.cpp @@ -112,12 +112,12 @@ void TransactionAcquire::trigger (Peer::ref peer) if (!mHaveRoot) { WriteLog (lsTRACE, TransactionAcquire) << "TransactionAcquire::trigger " << (peer ? "havePeer" : "noPeer") << " no root"; - ripple::TMGetLedger tmGL; + protocol::TMGetLedger tmGL; tmGL.set_ledgerhash (mHash.begin (), mHash.size ()); - tmGL.set_itype (ripple::liTS_CANDIDATE); + tmGL.set_itype (protocol::liTS_CANDIDATE); if (getTimeouts () != 0) - tmGL.set_querytype (ripple::qtINDIRECT); + tmGL.set_querytype (protocol::qtINDIRECT); * (tmGL.add_nodeids ()) = SHAMapNode ().getRawString (); sendRequest (tmGL, peer); @@ -140,12 +140,12 @@ void TransactionAcquire::trigger (Peer::ref peer) return; } - ripple::TMGetLedger tmGL; + protocol::TMGetLedger tmGL; tmGL.set_ledgerhash (mHash.begin (), mHash.size ()); - tmGL.set_itype (ripple::liTS_CANDIDATE); + tmGL.set_itype (protocol::liTS_CANDIDATE); if (getTimeouts () != 0) - tmGL.set_querytype (ripple::qtINDIRECT); + tmGL.set_querytype (protocol::qtINDIRECT); BOOST_FOREACH (SHAMapNode & it, nodeIDs) * (tmGL.add_nodeids ()) = it.getRawString ();