diff --git a/src/ripple/app/ledger/AccountStateSF.cpp b/src/ripple/app/ledger/AccountStateSF.cpp index 7ef576a1d..541efa184 100644 --- a/src/ripple/app/ledger/AccountStateSF.cpp +++ b/src/ripple/app/ledger/AccountStateSF.cpp @@ -27,8 +27,7 @@ namespace ripple { -AccountStateSF::AccountStateSF (std::uint32_t ledgerSeq) - : mLedgerSeq (ledgerSeq) +AccountStateSF::AccountStateSF() { } @@ -41,7 +40,8 @@ void AccountStateSF::gotNode (bool fromFilter, // VFALCO SHAMapSync filters should be passed the SHAMap, the // SHAMap should provide an accessor to get the injected Database, // and this should use that Database instad of getNodeStore - getApp().getNodeStore ().store (hotACCOUNT_NODE, mLedgerSeq, std::move (nodeData), nodeHash); + getApp().getNodeStore ().store ( + hotACCOUNT_NODE, std::move (nodeData), nodeHash); } bool AccountStateSF::haveNode (SHAMapNodeID const& id, diff --git a/src/ripple/app/ledger/AccountStateSF.h b/src/ripple/app/ledger/AccountStateSF.h index 7c0930c62..0cb55f6b1 100644 --- a/src/ripple/app/ledger/AccountStateSF.h +++ b/src/ripple/app/ledger/AccountStateSF.h @@ -29,7 +29,7 @@ namespace ripple { class AccountStateSF : public SHAMapSyncFilter { public: - explicit AccountStateSF (std::uint32_t ledgerSeq); + AccountStateSF(); // Note that the nodeData is overwritten by this call void gotNode (bool fromFilter, @@ -41,9 +41,6 @@ public: bool haveNode (SHAMapNodeID const& id, uint256 const& nodeHash, Blob& nodeData); - -private: - std::uint32_t mLedgerSeq; }; } // ripple diff --git a/src/ripple/app/ledger/InboundLedger.cpp b/src/ripple/app/ledger/InboundLedger.cpp index 1e241b00b..b15ab6fd0 100644 --- a/src/ripple/app/ledger/InboundLedger.cpp +++ b/src/ripple/app/ledger/InboundLedger.cpp @@ -141,8 +141,8 @@ bool InboundLedger::tryLocal () if (m_journal.trace) m_journal.trace << "Ledger header found in fetch pack"; mLedger = std::make_shared (data, true); - getApp().getNodeStore ().store (hotLEDGER, - mLedger->getLedgerSeq (), std::move (data), mHash); + getApp().getNodeStore ().store ( + hotLEDGER, std::move (data), mHash); } else { @@ -172,7 +172,7 @@ bool InboundLedger::tryLocal () } else { - TransactionStateSF filter (mLedger->getLedgerSeq ()); + TransactionStateSF filter; if (mLedger->peekTransactionMap ()->fetchRoot ( mLedger->getTransHash (), &filter)) @@ -200,7 +200,7 @@ bool InboundLedger::tryLocal () } else { - AccountStateSF filter (mLedger->getLedgerSeq ()); + AccountStateSF filter; if (mLedger->peekAccountStateMap ()->fetchRoot ( mLedger->getAccountHash (), &filter)) @@ -570,7 +570,7 @@ void InboundLedger::trigger (Peer::ptr const& peer) // VFALCO Why 256? Make this a constant nodeIDs.reserve (256); nodeHashes.reserve (256); - AccountStateSF filter (mSeq); + AccountStateSF filter; // Release the lock while we process the large state map sl.unlock(); @@ -649,7 +649,7 @@ void InboundLedger::trigger (Peer::ptr const& peer) std::vector nodeHashes; nodeIDs.reserve (256); nodeHashes.reserve (256); - TransactionStateSF filter (mSeq); + TransactionStateSF filter; mLedger->peekTransactionMap ()->getMissingNodes ( nodeIDs, nodeHashes, 256, &filter); @@ -804,8 +804,8 @@ bool InboundLedger::takeHeader (std::string const& data) Serializer s (data.size () + 4); s.add32 (HashPrefix::ledgerMaster); s.addRaw (data); - getApp().getNodeStore ().store (hotLEDGER, - mLedger->getLedgerSeq (), std::move (s.modData ()), mHash); + getApp().getNodeStore ().store ( + hotLEDGER, std::move (s.modData ()), mHash); progress (); @@ -841,7 +841,7 @@ bool InboundLedger::takeTxNode (const std::list& nodeIDs, std::list::const_iterator nodeIDit = nodeIDs.begin (); std::list< Blob >::const_iterator nodeDatait = data.begin (); - TransactionStateSF tFilter (mLedger->getLedgerSeq ()); + TransactionStateSF tFilter; while (nodeIDit != nodeIDs.end ()) { @@ -908,7 +908,7 @@ bool InboundLedger::takeAsNode (const std::list& nodeIDs, std::list::const_iterator nodeIDit = nodeIDs.begin (); std::list< Blob >::const_iterator nodeDatait = data.begin (); - AccountStateSF tFilter (mLedger->getLedgerSeq ()); + AccountStateSF tFilter; while (nodeIDit != nodeIDs.end ()) { @@ -972,7 +972,7 @@ bool InboundLedger::takeAsRootNode (Blob const& data, SHAMapAddNode& san) return false; } - AccountStateSF tFilter (mLedger->getLedgerSeq ()); + AccountStateSF tFilter; san += mLedger->peekAccountStateMap ()->addRootNode ( mLedger->getAccountHash (), data, snfWIRE, &tFilter); return san.isGood(); @@ -996,7 +996,7 @@ bool InboundLedger::takeTxRootNode (Blob const& data, SHAMapAddNode& san) return false; } - TransactionStateSF tFilter (mLedger->getLedgerSeq ()); + TransactionStateSF tFilter; san += mLedger->peekTransactionMap ()->addRootNode ( mLedger->getTransHash (), data, snfWIRE, &tFilter); return san.isGood(); @@ -1015,7 +1015,7 @@ std::vector InboundLedger::getNeededHashes () if (!mHaveState) { - AccountStateSF filter (mLedger->getLedgerSeq ()); + AccountStateSF filter; // VFALCO NOTE What's the number 4? for (auto const& h : mLedger->getNeededAccountStateHashes (4, &filter)) { @@ -1026,7 +1026,7 @@ std::vector InboundLedger::getNeededHashes () if (!mHaveTransactions) { - TransactionStateSF filter (mLedger->getLedgerSeq ()); + TransactionStateSF filter; // VFALCO NOTE What's the number 4? for (auto const& h : mLedger->getNeededTransactionHashes (4, &filter)) { diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 31766c76c..a05f05402 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -688,7 +688,7 @@ bool Ledger::saveValidatedLedger (bool current) s.add32 (HashPrefix::ledgerMaster); addRaw (s); getApp().getNodeStore ().store ( - hotLEDGER, mLedgerSeq, std::move (s.modData ()), mHash); + hotLEDGER, std::move (s.modData ()), mHash); } AcceptedLedger::pointer aLedger; diff --git a/src/ripple/app/ledger/TransactionStateSF.cpp b/src/ripple/app/ledger/TransactionStateSF.cpp index af83add86..2060de4ff 100644 --- a/src/ripple/app/ledger/TransactionStateSF.cpp +++ b/src/ripple/app/ledger/TransactionStateSF.cpp @@ -27,8 +27,7 @@ namespace ripple { -TransactionStateSF::TransactionStateSF (std::uint32_t ledgerSeq) - : mLedgerSeq (ledgerSeq) +TransactionStateSF::TransactionStateSF() { } @@ -43,7 +42,6 @@ void TransactionStateSF::gotNode (bool fromFilter, // and this should use that Database instad of getNodeStore getApp().getNodeStore ().store ( (type == SHAMapTreeNode::tnTRANSACTION_NM) ? hotTRANSACTION : hotTRANSACTION_NODE, - mLedgerSeq, std::move (nodeData), nodeHash); } diff --git a/src/ripple/app/ledger/TransactionStateSF.h b/src/ripple/app/ledger/TransactionStateSF.h index 9e4a4d344..bacf72056 100644 --- a/src/ripple/app/ledger/TransactionStateSF.h +++ b/src/ripple/app/ledger/TransactionStateSF.h @@ -30,7 +30,7 @@ namespace ripple { class TransactionStateSF : public SHAMapSyncFilter { public: - explicit TransactionStateSF (std::uint32_t ledgerSeq); + TransactionStateSF(); // Note that the nodeData is overwritten by this call void gotNode (bool fromFilter, @@ -42,9 +42,6 @@ public: bool haveNode (SHAMapNodeID const& id, uint256 const& nodeHash, Blob& nodeData); - -private: - std::uint32_t mLedgerSeq; }; } // ripple diff --git a/src/ripple/app/node/SqliteFactory.cpp b/src/ripple/app/node/SqliteFactory.cpp index 56be1a26b..2f85d60a4 100644 --- a/src/ripple/app/node/SqliteFactory.cpp +++ b/src/ripple/app/node/SqliteFactory.cpp @@ -27,6 +27,8 @@ namespace ripple { +// VFALCO NOTE LedgerIndex in CommittedObjects is obsolete + static const char* s_nodeStoreDBInit [] = { "PRAGMA synchronous=NORMAL;", @@ -94,7 +96,7 @@ public: uint256 const hash (uint256::fromVoid (key)); static SqliteStatement pSt (m_db->getDB()->getSqliteDB(), - "SELECT ObjType,LedgerIndex,Object FROM CommittedObjects WHERE Hash = ?;"); + "SELECT ObjType,Object FROM CommittedObjects WHERE Hash = ?;"); pSt.bind (1, to_string (hash)); @@ -102,10 +104,9 @@ public: { // VFALCO NOTE This is unfortunately needed, // the DatabaseCon creates the blob? - Blob data (pSt.getBlob (2)); + Blob data (pSt.getBlob(1)); *pObject = NodeObject::createObject ( getTypeFromString (pSt.peekString (0)), - pSt.getUInt32 (1), std::move(data), hash); } @@ -131,15 +132,13 @@ public: void storeBatch (NodeStore::Batch const& batch) { - // VFALCO TODO Rewrite this to use Beast::db - auto sl (m_db->lock()); static SqliteStatement pStB (m_db->getDB()->getSqliteDB(), "BEGIN TRANSACTION;"); static SqliteStatement pStE (m_db->getDB()->getSqliteDB(), "END TRANSACTION;"); static SqliteStatement pSt (m_db->getDB()->getSqliteDB(), "INSERT OR IGNORE INTO CommittedObjects " - "(Hash,ObjType,LedgerIndex,Object) VALUES (?, ?, ?, ?);"); + "(Hash,ObjType,Object) VALUES (?, ?, ?, ?);"); pStB.step(); pStB.reset(); @@ -163,7 +162,7 @@ public: uint256 hash; static SqliteStatement pSt(m_db->getDB()->getSqliteDB(), - "SELECT ObjType,LedgerIndex,Object,Hash FROM CommittedObjects;"); + "SELECT ObjType,Object,Hash FROM CommittedObjects;"); while (pSt.isRow (pSt.step())) { @@ -171,10 +170,9 @@ public: // VFALCO NOTE This is unfortunately needed, // the DatabaseCon creates the blob? - Blob data (pSt.getBlob (2)); + Blob data (pSt.getBlob (1)); NodeObject::Ptr const object (NodeObject::createObject ( getTypeFromString (pSt.peekString (0)), - pSt.getUInt32 (1), std::move(data), hash)); @@ -207,8 +205,7 @@ public: statement.bind(1, to_string (object->getHash())); statement.bind(2, type); - statement.bind(3, object->getLedgerIndex()); - statement.bindStatic(4, object->getData()); + statement.bindStatic(3, object->getData()); } NodeObjectType getTypeFromString (std::string const& s) diff --git a/src/ripple/nodestore/Database.h b/src/ripple/nodestore/Database.h index 0e60c1be6..255672352 100644 --- a/src/ripple/nodestore/Database.h +++ b/src/ripple/nodestore/Database.h @@ -106,7 +106,6 @@ public: @return `true` if the object was stored? */ virtual void store (NodeObjectType type, - std::uint32_t ledgerIndex, Blob&& data, uint256 const& hash) = 0; diff --git a/src/ripple/nodestore/NodeObject.h b/src/ripple/nodestore/NodeObject.h index 50b35adbe..e4135966b 100644 --- a/src/ripple/nodestore/NodeObject.h +++ b/src/ripple/nodestore/NodeObject.h @@ -77,7 +77,6 @@ private: public: // This constructor is private, use createObject instead. NodeObject (NodeObjectType type, - LedgerIndex ledgerIndex, Blob&& data, uint256 const& hash, PrivateAccess); @@ -94,7 +93,6 @@ public: @param hash The 256-bit hash of the payload data. */ static Ptr createObject (NodeObjectType type, - LedgerIndex ledgerIndex, Blob&& data, uint256 const& hash); @@ -106,10 +104,6 @@ public: */ uint256 const& getHash () const; - /** Retrieve the ledger index in which this object appears. - */ - LedgerIndex getLedgerIndex() const; - /** Retrieve the binary data. */ Blob const& getData () const; @@ -136,7 +130,6 @@ public: private: NodeObjectType mType; uint256 mHash; - LedgerIndex mLedgerIndex; Blob mData; }; diff --git a/src/ripple/nodestore/impl/DatabaseImp.h b/src/ripple/nodestore/impl/DatabaseImp.h index 3fed69354..b556c22c7 100644 --- a/src/ripple/nodestore/impl/DatabaseImp.h +++ b/src/ripple/nodestore/impl/DatabaseImp.h @@ -309,21 +309,19 @@ public: //------------------------------------------------------------------------------ void store (NodeObjectType type, - std::uint32_t index, Blob&& data, - uint256 const& hash) + uint256 const& hash) override { - storeInternal (type, index, std::move(data), hash, *m_backend.get()); + storeInternal (type, std::move(data), hash, *m_backend.get()); } void storeInternal (NodeObjectType type, - std::uint32_t index, Blob&& data, uint256 const& hash, Backend& backend) { - NodeObject::Ptr object = NodeObject::createObject(type, index, - std::move(data), hash); + NodeObject::Ptr object = NodeObject::createObject( + type, std::move(data), hash); #if RIPPLE_VERIFY_NODEOBJECT_KEYS assert (hash == getSHA512Half (data)); diff --git a/src/ripple/nodestore/impl/DatabaseRotatingImp.h b/src/ripple/nodestore/impl/DatabaseRotatingImp.h index 493b84a54..ebcf123f2 100644 --- a/src/ripple/nodestore/impl/DatabaseRotatingImp.h +++ b/src/ripple/nodestore/impl/DatabaseRotatingImp.h @@ -110,11 +110,10 @@ public: } void store (NodeObjectType type, - std::uint32_t index, Blob&& data, uint256 const& hash) override { - storeInternal (type, index, std::move(data), hash, + storeInternal (type, std::move(data), hash, *getWritableBackend()); } diff --git a/src/ripple/nodestore/impl/DecodedBlob.cpp b/src/ripple/nodestore/impl/DecodedBlob.cpp index 36b8a0aad..e16268ef0 100644 --- a/src/ripple/nodestore/impl/DecodedBlob.cpp +++ b/src/ripple/nodestore/impl/DecodedBlob.cpp @@ -40,17 +40,10 @@ DecodedBlob::DecodedBlob (void const* key, void const* value, int valueBytes) m_success = false; m_key = key; // VFALCO NOTE Ledger indexes should have started at 1 - m_ledgerIndex = LedgerIndex (-1); m_objectType = hotUNKNOWN; m_objectData = nullptr; m_dataBytes = std::max (0, valueBytes - 9); - if (valueBytes > 4) - { - LedgerIndex const* index = static_cast (value); - m_ledgerIndex = beast::ByteOrder::swapIfLittleEndian (*index); - } - // VFALCO NOTE What about bytes 4 through 7 inclusive? if (valueBytes > 8) @@ -90,7 +83,7 @@ NodeObject::Ptr DecodedBlob::createObject () Blob data(m_objectData, m_objectData + m_dataBytes); object = NodeObject::createObject ( - m_objectType, m_ledgerIndex, std::move(data), uint256::fromVoid(m_key)); + m_objectType, std::move(data), uint256::fromVoid(m_key)); } return object; diff --git a/src/ripple/nodestore/impl/DecodedBlob.h b/src/ripple/nodestore/impl/DecodedBlob.h index b46ad15bf..2f692c442 100644 --- a/src/ripple/nodestore/impl/DecodedBlob.h +++ b/src/ripple/nodestore/impl/DecodedBlob.h @@ -51,7 +51,6 @@ private: bool m_success; void const* m_key; - LedgerIndex m_ledgerIndex; NodeObjectType m_objectType; unsigned char const* m_objectData; int m_dataBytes; diff --git a/src/ripple/nodestore/impl/EncodedBlob.cpp b/src/ripple/nodestore/impl/EncodedBlob.cpp index db9fbfa4b..67cf26f1e 100644 --- a/src/ripple/nodestore/impl/EncodedBlob.cpp +++ b/src/ripple/nodestore/impl/EncodedBlob.cpp @@ -27,30 +27,27 @@ namespace NodeStore { void EncodedBlob::prepare (NodeObject::Ptr const& object) { - m_key = object->getHash ().begin (); + m_key = object->getHash().begin (); // This is how many bytes we need in the flat data m_size = object->getData ().size () + 9; - m_data.ensureSize (m_size); - - // These sizes must be the same! - static_assert (sizeof (std::uint32_t) == sizeof (object->getLedgerIndex ()), - "Ledger Indices must be exactly 32-bits long."); + m_data.ensureSize(m_size); { - std::uint32_t* buf = static_cast (m_data.getData ()); - - buf [0] = beast::ByteOrder::swapIfLittleEndian (object->getLedgerIndex ()); - buf [1] = beast::ByteOrder::swapIfLittleEndian (object->getLedgerIndex ()); + // these 8 bytes are unused + std::uint64_t* buf = static_cast < + std::uint64_t*>(m_data.getData ()); + *buf = 0; } { - unsigned char* buf = static_cast (m_data.getData ()); - - buf [8] = static_cast (object->getType ()); - - memcpy (&buf [9], object->getData ().data (), object->getData ().size ()); + unsigned char* buf = static_cast < + unsigned char*> (m_data.getData ()); + buf [8] = static_cast < + unsigned char> (object->getType ()); + memcpy (&buf [9], object->getData ().data(), + object->getData ().size()); } } diff --git a/src/ripple/nodestore/impl/NodeObject.cpp b/src/ripple/nodestore/impl/NodeObject.cpp index d760c4a55..97a1efa48 100644 --- a/src/ripple/nodestore/impl/NodeObject.cpp +++ b/src/ripple/nodestore/impl/NodeObject.cpp @@ -27,13 +27,11 @@ namespace ripple { NodeObject::NodeObject ( NodeObjectType type, - LedgerIndex ledgerIndex, Blob&& data, uint256 const& hash, PrivateAccess) : mType (type) , mHash (hash) - , mLedgerIndex (ledgerIndex) { mData = std::move (data); } @@ -41,12 +39,11 @@ NodeObject::NodeObject ( NodeObject::Ptr NodeObject::createObject ( NodeObjectType type, - LedgerIndex ledgerIndex, Blob&& data, uint256 const& hash) { return std::make_shared ( - type, ledgerIndex, std::move (data), hash, PrivateAccess ()); + type, std::move (data), hash, PrivateAccess ()); } NodeObjectType @@ -61,12 +58,6 @@ NodeObject::getHash () const return mHash; } -LedgerIndex -NodeObject::getLedgerIndex () const -{ - return mLedgerIndex; -} - Blob const& NodeObject::getData () const { @@ -82,9 +73,6 @@ NodeObject::isCloneOf (NodeObject::Ptr const& other) const if (mHash != other->mHash) return false; - if (mLedgerIndex != other->mLedgerIndex) - return false; - if (mData != other->mData) return false; diff --git a/src/ripple/nodestore/tests/Base.test.h b/src/ripple/nodestore/tests/Base.test.h index 49b5b4cc1..fa322cab3 100644 --- a/src/ripple/nodestore/tests/Base.test.h +++ b/src/ripple/nodestore/tests/Base.test.h @@ -66,8 +66,6 @@ public: break; }; - LedgerIndex ledgerIndex = 1 + r.nextInt (1024 * 1024); - uint256 hash; r.fillBitsRandomly (hash.begin (), hash.size ()); @@ -77,7 +75,7 @@ public: r.fillBitsRandomly (data.data (), payloadBytes); - return NodeObject::createObject(type, ledgerIndex, std::move(data), hash); + return NodeObject::createObject(type, std::move(data), hash); } private: @@ -176,7 +174,6 @@ public: Blob data (object->getData ()); db.store (object->getType (), - object->getLedgerIndex (), std::move (data), object->getHash ()); } diff --git a/src/ripple/nodestore/tests/Timing.test.cpp b/src/ripple/nodestore/tests/Timing.test.cpp index 644a13b2f..505575c65 100644 --- a/src/ripple/nodestore/tests/Timing.test.cpp +++ b/src/ripple/nodestore/tests/Timing.test.cpp @@ -84,7 +84,6 @@ private: beast::xor_shift_engine gen_; std::uint8_t prefix_; - std::uniform_int_distribution d_seq_; std::uniform_int_distribution d_type_; std::uniform_int_distribution d_size_; @@ -92,7 +91,6 @@ public: explicit Sequence(std::uint8_t prefix) : prefix_ (prefix) - , d_seq_ (minLedger, maxLedger) , d_type_ (hotLEDGER, hotTRANSACTION_NODE) , d_size_ (minSize, maxSize) { @@ -122,7 +120,7 @@ public: rngcpy (&value[0], value.size(), gen_); return NodeObject::createObject ( static_cast(d_type_(gen_)), - d_seq_(gen_), std::move(value), key); + std::move(value), key); } // returns a batch of NodeObjects starting at n diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index b4ee59b98..c7ed6881c 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -1400,8 +1400,7 @@ PeerImp::onMessage (std::shared_ptr const& m) if (obj.has_nodeid ()) newObj.set_index (obj.nodeid ()); - if (!reply.has_seq () && (hObj->getLedgerIndex () != 0)) - reply.set_seq (hObj->getLedgerIndex ()); + // VFALCO NOTE "seq" in the message is obsolete } } } diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 6c459b669..e9a2a69fd 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -943,8 +943,8 @@ void SHAMap::writeNode ( Serializer s; node->addRaw (s, snfPREFIX); - db_.store (t, seq, - std::move (s.modData ()), node->getNodeHash ()); + db_.store (t, std::move (s.modData()), + node->getNodeHash ()); } // We can't modify an inner node someone else might have a