mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Remove obsolete NodeObject fields:
Legacy fields of NodeObject are removed, as they are no longer used and there is a space savings from omitting them: * Remove LedgerIndex
This commit is contained in:
@@ -27,8 +27,7 @@
|
|||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
AccountStateSF::AccountStateSF (std::uint32_t ledgerSeq)
|
AccountStateSF::AccountStateSF()
|
||||||
: mLedgerSeq (ledgerSeq)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,8 @@ void AccountStateSF::gotNode (bool fromFilter,
|
|||||||
// VFALCO SHAMapSync filters should be passed the SHAMap, the
|
// VFALCO SHAMapSync filters should be passed the SHAMap, the
|
||||||
// SHAMap should provide an accessor to get the injected Database,
|
// SHAMap should provide an accessor to get the injected Database,
|
||||||
// and this should use that Database instad of getNodeStore
|
// 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,
|
bool AccountStateSF::haveNode (SHAMapNodeID const& id,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace ripple {
|
|||||||
class AccountStateSF : public SHAMapSyncFilter
|
class AccountStateSF : public SHAMapSyncFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AccountStateSF (std::uint32_t ledgerSeq);
|
AccountStateSF();
|
||||||
|
|
||||||
// Note that the nodeData is overwritten by this call
|
// Note that the nodeData is overwritten by this call
|
||||||
void gotNode (bool fromFilter,
|
void gotNode (bool fromFilter,
|
||||||
@@ -41,9 +41,6 @@ public:
|
|||||||
bool haveNode (SHAMapNodeID const& id,
|
bool haveNode (SHAMapNodeID const& id,
|
||||||
uint256 const& nodeHash,
|
uint256 const& nodeHash,
|
||||||
Blob& nodeData);
|
Blob& nodeData);
|
||||||
|
|
||||||
private:
|
|
||||||
std::uint32_t mLedgerSeq;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ bool InboundLedger::tryLocal ()
|
|||||||
if (m_journal.trace) m_journal.trace <<
|
if (m_journal.trace) m_journal.trace <<
|
||||||
"Ledger header found in fetch pack";
|
"Ledger header found in fetch pack";
|
||||||
mLedger = std::make_shared<Ledger> (data, true);
|
mLedger = std::make_shared<Ledger> (data, true);
|
||||||
getApp().getNodeStore ().store (hotLEDGER,
|
getApp().getNodeStore ().store (
|
||||||
mLedger->getLedgerSeq (), std::move (data), mHash);
|
hotLEDGER, std::move (data), mHash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -172,7 +172,7 @@ bool InboundLedger::tryLocal ()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TransactionStateSF filter (mLedger->getLedgerSeq ());
|
TransactionStateSF filter;
|
||||||
|
|
||||||
if (mLedger->peekTransactionMap ()->fetchRoot (
|
if (mLedger->peekTransactionMap ()->fetchRoot (
|
||||||
mLedger->getTransHash (), &filter))
|
mLedger->getTransHash (), &filter))
|
||||||
@@ -200,7 +200,7 @@ bool InboundLedger::tryLocal ()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AccountStateSF filter (mLedger->getLedgerSeq ());
|
AccountStateSF filter;
|
||||||
|
|
||||||
if (mLedger->peekAccountStateMap ()->fetchRoot (
|
if (mLedger->peekAccountStateMap ()->fetchRoot (
|
||||||
mLedger->getAccountHash (), &filter))
|
mLedger->getAccountHash (), &filter))
|
||||||
@@ -570,7 +570,7 @@ void InboundLedger::trigger (Peer::ptr const& peer)
|
|||||||
// VFALCO Why 256? Make this a constant
|
// VFALCO Why 256? Make this a constant
|
||||||
nodeIDs.reserve (256);
|
nodeIDs.reserve (256);
|
||||||
nodeHashes.reserve (256);
|
nodeHashes.reserve (256);
|
||||||
AccountStateSF filter (mSeq);
|
AccountStateSF filter;
|
||||||
|
|
||||||
// Release the lock while we process the large state map
|
// Release the lock while we process the large state map
|
||||||
sl.unlock();
|
sl.unlock();
|
||||||
@@ -649,7 +649,7 @@ void InboundLedger::trigger (Peer::ptr const& peer)
|
|||||||
std::vector<uint256> nodeHashes;
|
std::vector<uint256> nodeHashes;
|
||||||
nodeIDs.reserve (256);
|
nodeIDs.reserve (256);
|
||||||
nodeHashes.reserve (256);
|
nodeHashes.reserve (256);
|
||||||
TransactionStateSF filter (mSeq);
|
TransactionStateSF filter;
|
||||||
mLedger->peekTransactionMap ()->getMissingNodes (
|
mLedger->peekTransactionMap ()->getMissingNodes (
|
||||||
nodeIDs, nodeHashes, 256, &filter);
|
nodeIDs, nodeHashes, 256, &filter);
|
||||||
|
|
||||||
@@ -804,8 +804,8 @@ bool InboundLedger::takeHeader (std::string const& data)
|
|||||||
Serializer s (data.size () + 4);
|
Serializer s (data.size () + 4);
|
||||||
s.add32 (HashPrefix::ledgerMaster);
|
s.add32 (HashPrefix::ledgerMaster);
|
||||||
s.addRaw (data);
|
s.addRaw (data);
|
||||||
getApp().getNodeStore ().store (hotLEDGER,
|
getApp().getNodeStore ().store (
|
||||||
mLedger->getLedgerSeq (), std::move (s.modData ()), mHash);
|
hotLEDGER, std::move (s.modData ()), mHash);
|
||||||
|
|
||||||
progress ();
|
progress ();
|
||||||
|
|
||||||
@@ -841,7 +841,7 @@ bool InboundLedger::takeTxNode (const std::list<SHAMapNodeID>& nodeIDs,
|
|||||||
|
|
||||||
std::list<SHAMapNodeID>::const_iterator nodeIDit = nodeIDs.begin ();
|
std::list<SHAMapNodeID>::const_iterator nodeIDit = nodeIDs.begin ();
|
||||||
std::list< Blob >::const_iterator nodeDatait = data.begin ();
|
std::list< Blob >::const_iterator nodeDatait = data.begin ();
|
||||||
TransactionStateSF tFilter (mLedger->getLedgerSeq ());
|
TransactionStateSF tFilter;
|
||||||
|
|
||||||
while (nodeIDit != nodeIDs.end ())
|
while (nodeIDit != nodeIDs.end ())
|
||||||
{
|
{
|
||||||
@@ -908,7 +908,7 @@ bool InboundLedger::takeAsNode (const std::list<SHAMapNodeID>& nodeIDs,
|
|||||||
|
|
||||||
std::list<SHAMapNodeID>::const_iterator nodeIDit = nodeIDs.begin ();
|
std::list<SHAMapNodeID>::const_iterator nodeIDit = nodeIDs.begin ();
|
||||||
std::list< Blob >::const_iterator nodeDatait = data.begin ();
|
std::list< Blob >::const_iterator nodeDatait = data.begin ();
|
||||||
AccountStateSF tFilter (mLedger->getLedgerSeq ());
|
AccountStateSF tFilter;
|
||||||
|
|
||||||
while (nodeIDit != nodeIDs.end ())
|
while (nodeIDit != nodeIDs.end ())
|
||||||
{
|
{
|
||||||
@@ -972,7 +972,7 @@ bool InboundLedger::takeAsRootNode (Blob const& data, SHAMapAddNode& san)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountStateSF tFilter (mLedger->getLedgerSeq ());
|
AccountStateSF tFilter;
|
||||||
san += mLedger->peekAccountStateMap ()->addRootNode (
|
san += mLedger->peekAccountStateMap ()->addRootNode (
|
||||||
mLedger->getAccountHash (), data, snfWIRE, &tFilter);
|
mLedger->getAccountHash (), data, snfWIRE, &tFilter);
|
||||||
return san.isGood();
|
return san.isGood();
|
||||||
@@ -996,7 +996,7 @@ bool InboundLedger::takeTxRootNode (Blob const& data, SHAMapAddNode& san)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionStateSF tFilter (mLedger->getLedgerSeq ());
|
TransactionStateSF tFilter;
|
||||||
san += mLedger->peekTransactionMap ()->addRootNode (
|
san += mLedger->peekTransactionMap ()->addRootNode (
|
||||||
mLedger->getTransHash (), data, snfWIRE, &tFilter);
|
mLedger->getTransHash (), data, snfWIRE, &tFilter);
|
||||||
return san.isGood();
|
return san.isGood();
|
||||||
@@ -1015,7 +1015,7 @@ std::vector<InboundLedger::neededHash_t> InboundLedger::getNeededHashes ()
|
|||||||
|
|
||||||
if (!mHaveState)
|
if (!mHaveState)
|
||||||
{
|
{
|
||||||
AccountStateSF filter (mLedger->getLedgerSeq ());
|
AccountStateSF filter;
|
||||||
// VFALCO NOTE What's the number 4?
|
// VFALCO NOTE What's the number 4?
|
||||||
for (auto const& h : mLedger->getNeededAccountStateHashes (4, &filter))
|
for (auto const& h : mLedger->getNeededAccountStateHashes (4, &filter))
|
||||||
{
|
{
|
||||||
@@ -1026,7 +1026,7 @@ std::vector<InboundLedger::neededHash_t> InboundLedger::getNeededHashes ()
|
|||||||
|
|
||||||
if (!mHaveTransactions)
|
if (!mHaveTransactions)
|
||||||
{
|
{
|
||||||
TransactionStateSF filter (mLedger->getLedgerSeq ());
|
TransactionStateSF filter;
|
||||||
// VFALCO NOTE What's the number 4?
|
// VFALCO NOTE What's the number 4?
|
||||||
for (auto const& h : mLedger->getNeededTransactionHashes (4, &filter))
|
for (auto const& h : mLedger->getNeededTransactionHashes (4, &filter))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ bool Ledger::saveValidatedLedger (bool current)
|
|||||||
s.add32 (HashPrefix::ledgerMaster);
|
s.add32 (HashPrefix::ledgerMaster);
|
||||||
addRaw (s);
|
addRaw (s);
|
||||||
getApp().getNodeStore ().store (
|
getApp().getNodeStore ().store (
|
||||||
hotLEDGER, mLedgerSeq, std::move (s.modData ()), mHash);
|
hotLEDGER, std::move (s.modData ()), mHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
AcceptedLedger::pointer aLedger;
|
AcceptedLedger::pointer aLedger;
|
||||||
|
|||||||
@@ -27,8 +27,7 @@
|
|||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
TransactionStateSF::TransactionStateSF (std::uint32_t ledgerSeq)
|
TransactionStateSF::TransactionStateSF()
|
||||||
: mLedgerSeq (ledgerSeq)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +42,6 @@ void TransactionStateSF::gotNode (bool fromFilter,
|
|||||||
// and this should use that Database instad of getNodeStore
|
// and this should use that Database instad of getNodeStore
|
||||||
getApp().getNodeStore ().store (
|
getApp().getNodeStore ().store (
|
||||||
(type == SHAMapTreeNode::tnTRANSACTION_NM) ? hotTRANSACTION : hotTRANSACTION_NODE,
|
(type == SHAMapTreeNode::tnTRANSACTION_NM) ? hotTRANSACTION : hotTRANSACTION_NODE,
|
||||||
mLedgerSeq,
|
|
||||||
std::move (nodeData),
|
std::move (nodeData),
|
||||||
nodeHash);
|
nodeHash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace ripple {
|
|||||||
class TransactionStateSF : public SHAMapSyncFilter
|
class TransactionStateSF : public SHAMapSyncFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TransactionStateSF (std::uint32_t ledgerSeq);
|
TransactionStateSF();
|
||||||
|
|
||||||
// Note that the nodeData is overwritten by this call
|
// Note that the nodeData is overwritten by this call
|
||||||
void gotNode (bool fromFilter,
|
void gotNode (bool fromFilter,
|
||||||
@@ -42,9 +42,6 @@ public:
|
|||||||
bool haveNode (SHAMapNodeID const& id,
|
bool haveNode (SHAMapNodeID const& id,
|
||||||
uint256 const& nodeHash,
|
uint256 const& nodeHash,
|
||||||
Blob& nodeData);
|
Blob& nodeData);
|
||||||
|
|
||||||
private:
|
|
||||||
std::uint32_t mLedgerSeq;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
|
// VFALCO NOTE LedgerIndex in CommittedObjects is obsolete
|
||||||
|
|
||||||
static const char* s_nodeStoreDBInit [] =
|
static const char* s_nodeStoreDBInit [] =
|
||||||
{
|
{
|
||||||
"PRAGMA synchronous=NORMAL;",
|
"PRAGMA synchronous=NORMAL;",
|
||||||
@@ -94,7 +96,7 @@ public:
|
|||||||
uint256 const hash (uint256::fromVoid (key));
|
uint256 const hash (uint256::fromVoid (key));
|
||||||
|
|
||||||
static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
|
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));
|
pSt.bind (1, to_string (hash));
|
||||||
|
|
||||||
@@ -102,10 +104,9 @@ public:
|
|||||||
{
|
{
|
||||||
// VFALCO NOTE This is unfortunately needed,
|
// VFALCO NOTE This is unfortunately needed,
|
||||||
// the DatabaseCon creates the blob?
|
// the DatabaseCon creates the blob?
|
||||||
Blob data (pSt.getBlob (2));
|
Blob data (pSt.getBlob(1));
|
||||||
*pObject = NodeObject::createObject (
|
*pObject = NodeObject::createObject (
|
||||||
getTypeFromString (pSt.peekString (0)),
|
getTypeFromString (pSt.peekString (0)),
|
||||||
pSt.getUInt32 (1),
|
|
||||||
std::move(data),
|
std::move(data),
|
||||||
hash);
|
hash);
|
||||||
}
|
}
|
||||||
@@ -131,15 +132,13 @@ public:
|
|||||||
|
|
||||||
void storeBatch (NodeStore::Batch const& batch)
|
void storeBatch (NodeStore::Batch const& batch)
|
||||||
{
|
{
|
||||||
// VFALCO TODO Rewrite this to use Beast::db
|
|
||||||
|
|
||||||
auto sl (m_db->lock());
|
auto sl (m_db->lock());
|
||||||
|
|
||||||
static SqliteStatement pStB (m_db->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
|
static SqliteStatement pStB (m_db->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
|
||||||
static SqliteStatement pStE (m_db->getDB()->getSqliteDB(), "END TRANSACTION;");
|
static SqliteStatement pStE (m_db->getDB()->getSqliteDB(), "END TRANSACTION;");
|
||||||
static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
|
static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
|
||||||
"INSERT OR IGNORE INTO CommittedObjects "
|
"INSERT OR IGNORE INTO CommittedObjects "
|
||||||
"(Hash,ObjType,LedgerIndex,Object) VALUES (?, ?, ?, ?);");
|
"(Hash,ObjType,Object) VALUES (?, ?, ?, ?);");
|
||||||
|
|
||||||
pStB.step();
|
pStB.step();
|
||||||
pStB.reset();
|
pStB.reset();
|
||||||
@@ -163,7 +162,7 @@ public:
|
|||||||
uint256 hash;
|
uint256 hash;
|
||||||
|
|
||||||
static SqliteStatement pSt(m_db->getDB()->getSqliteDB(),
|
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()))
|
while (pSt.isRow (pSt.step()))
|
||||||
{
|
{
|
||||||
@@ -171,10 +170,9 @@ public:
|
|||||||
|
|
||||||
// VFALCO NOTE This is unfortunately needed,
|
// VFALCO NOTE This is unfortunately needed,
|
||||||
// the DatabaseCon creates the blob?
|
// the DatabaseCon creates the blob?
|
||||||
Blob data (pSt.getBlob (2));
|
Blob data (pSt.getBlob (1));
|
||||||
NodeObject::Ptr const object (NodeObject::createObject (
|
NodeObject::Ptr const object (NodeObject::createObject (
|
||||||
getTypeFromString (pSt.peekString (0)),
|
getTypeFromString (pSt.peekString (0)),
|
||||||
pSt.getUInt32 (1),
|
|
||||||
std::move(data),
|
std::move(data),
|
||||||
hash));
|
hash));
|
||||||
|
|
||||||
@@ -207,8 +205,7 @@ public:
|
|||||||
|
|
||||||
statement.bind(1, to_string (object->getHash()));
|
statement.bind(1, to_string (object->getHash()));
|
||||||
statement.bind(2, type);
|
statement.bind(2, type);
|
||||||
statement.bind(3, object->getLedgerIndex());
|
statement.bindStatic(3, object->getData());
|
||||||
statement.bindStatic(4, object->getData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeObjectType getTypeFromString (std::string const& s)
|
NodeObjectType getTypeFromString (std::string const& s)
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public:
|
|||||||
@return `true` if the object was stored?
|
@return `true` if the object was stored?
|
||||||
*/
|
*/
|
||||||
virtual void store (NodeObjectType type,
|
virtual void store (NodeObjectType type,
|
||||||
std::uint32_t ledgerIndex,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash) = 0;
|
uint256 const& hash) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
// This constructor is private, use createObject instead.
|
// This constructor is private, use createObject instead.
|
||||||
NodeObject (NodeObjectType type,
|
NodeObject (NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash,
|
uint256 const& hash,
|
||||||
PrivateAccess);
|
PrivateAccess);
|
||||||
@@ -94,7 +93,6 @@ public:
|
|||||||
@param hash The 256-bit hash of the payload data.
|
@param hash The 256-bit hash of the payload data.
|
||||||
*/
|
*/
|
||||||
static Ptr createObject (NodeObjectType type,
|
static Ptr createObject (NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash);
|
uint256 const& hash);
|
||||||
|
|
||||||
@@ -106,10 +104,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint256 const& getHash () const;
|
uint256 const& getHash () const;
|
||||||
|
|
||||||
/** Retrieve the ledger index in which this object appears.
|
|
||||||
*/
|
|
||||||
LedgerIndex getLedgerIndex() const;
|
|
||||||
|
|
||||||
/** Retrieve the binary data.
|
/** Retrieve the binary data.
|
||||||
*/
|
*/
|
||||||
Blob const& getData () const;
|
Blob const& getData () const;
|
||||||
@@ -136,7 +130,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
NodeObjectType mType;
|
NodeObjectType mType;
|
||||||
uint256 mHash;
|
uint256 mHash;
|
||||||
LedgerIndex mLedgerIndex;
|
|
||||||
Blob mData;
|
Blob mData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -309,21 +309,19 @@ public:
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void store (NodeObjectType type,
|
void store (NodeObjectType type,
|
||||||
std::uint32_t index,
|
|
||||||
Blob&& data,
|
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,
|
void storeInternal (NodeObjectType type,
|
||||||
std::uint32_t index,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash,
|
uint256 const& hash,
|
||||||
Backend& backend)
|
Backend& backend)
|
||||||
{
|
{
|
||||||
NodeObject::Ptr object = NodeObject::createObject(type, index,
|
NodeObject::Ptr object = NodeObject::createObject(
|
||||||
std::move(data), hash);
|
type, std::move(data), hash);
|
||||||
|
|
||||||
#if RIPPLE_VERIFY_NODEOBJECT_KEYS
|
#if RIPPLE_VERIFY_NODEOBJECT_KEYS
|
||||||
assert (hash == getSHA512Half (data));
|
assert (hash == getSHA512Half (data));
|
||||||
|
|||||||
@@ -110,11 +110,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void store (NodeObjectType type,
|
void store (NodeObjectType type,
|
||||||
std::uint32_t index,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash) override
|
uint256 const& hash) override
|
||||||
{
|
{
|
||||||
storeInternal (type, index, std::move(data), hash,
|
storeInternal (type, std::move(data), hash,
|
||||||
*getWritableBackend());
|
*getWritableBackend());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,17 +40,10 @@ DecodedBlob::DecodedBlob (void const* key, void const* value, int valueBytes)
|
|||||||
m_success = false;
|
m_success = false;
|
||||||
m_key = key;
|
m_key = key;
|
||||||
// VFALCO NOTE Ledger indexes should have started at 1
|
// VFALCO NOTE Ledger indexes should have started at 1
|
||||||
m_ledgerIndex = LedgerIndex (-1);
|
|
||||||
m_objectType = hotUNKNOWN;
|
m_objectType = hotUNKNOWN;
|
||||||
m_objectData = nullptr;
|
m_objectData = nullptr;
|
||||||
m_dataBytes = std::max (0, valueBytes - 9);
|
m_dataBytes = std::max (0, valueBytes - 9);
|
||||||
|
|
||||||
if (valueBytes > 4)
|
|
||||||
{
|
|
||||||
LedgerIndex const* index = static_cast <LedgerIndex const*> (value);
|
|
||||||
m_ledgerIndex = beast::ByteOrder::swapIfLittleEndian (*index);
|
|
||||||
}
|
|
||||||
|
|
||||||
// VFALCO NOTE What about bytes 4 through 7 inclusive?
|
// VFALCO NOTE What about bytes 4 through 7 inclusive?
|
||||||
|
|
||||||
if (valueBytes > 8)
|
if (valueBytes > 8)
|
||||||
@@ -90,7 +83,7 @@ NodeObject::Ptr DecodedBlob::createObject ()
|
|||||||
Blob data(m_objectData, m_objectData + m_dataBytes);
|
Blob data(m_objectData, m_objectData + m_dataBytes);
|
||||||
|
|
||||||
object = NodeObject::createObject (
|
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;
|
return object;
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ private:
|
|||||||
bool m_success;
|
bool m_success;
|
||||||
|
|
||||||
void const* m_key;
|
void const* m_key;
|
||||||
LedgerIndex m_ledgerIndex;
|
|
||||||
NodeObjectType m_objectType;
|
NodeObjectType m_objectType;
|
||||||
unsigned char const* m_objectData;
|
unsigned char const* m_objectData;
|
||||||
int m_dataBytes;
|
int m_dataBytes;
|
||||||
|
|||||||
@@ -27,30 +27,27 @@ namespace NodeStore {
|
|||||||
void
|
void
|
||||||
EncodedBlob::prepare (NodeObject::Ptr const& object)
|
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
|
// This is how many bytes we need in the flat data
|
||||||
m_size = object->getData ().size () + 9;
|
m_size = object->getData ().size () + 9;
|
||||||
|
|
||||||
m_data.ensureSize (m_size);
|
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.");
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::uint32_t* buf = static_cast <std::uint32_t*> (m_data.getData ());
|
// these 8 bytes are unused
|
||||||
|
std::uint64_t* buf = static_cast <
|
||||||
buf [0] = beast::ByteOrder::swapIfLittleEndian (object->getLedgerIndex ());
|
std::uint64_t*>(m_data.getData ());
|
||||||
buf [1] = beast::ByteOrder::swapIfLittleEndian (object->getLedgerIndex ());
|
*buf = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned char* buf = static_cast <unsigned char*> (m_data.getData ());
|
unsigned char* buf = static_cast <
|
||||||
|
unsigned char*> (m_data.getData ());
|
||||||
buf [8] = static_cast <unsigned char> (object->getType ());
|
buf [8] = static_cast <
|
||||||
|
unsigned char> (object->getType ());
|
||||||
memcpy (&buf [9], object->getData ().data (), object->getData ().size ());
|
memcpy (&buf [9], object->getData ().data(),
|
||||||
|
object->getData ().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,13 +27,11 @@ namespace ripple {
|
|||||||
|
|
||||||
NodeObject::NodeObject (
|
NodeObject::NodeObject (
|
||||||
NodeObjectType type,
|
NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash,
|
uint256 const& hash,
|
||||||
PrivateAccess)
|
PrivateAccess)
|
||||||
: mType (type)
|
: mType (type)
|
||||||
, mHash (hash)
|
, mHash (hash)
|
||||||
, mLedgerIndex (ledgerIndex)
|
|
||||||
{
|
{
|
||||||
mData = std::move (data);
|
mData = std::move (data);
|
||||||
}
|
}
|
||||||
@@ -41,12 +39,11 @@ NodeObject::NodeObject (
|
|||||||
NodeObject::Ptr
|
NodeObject::Ptr
|
||||||
NodeObject::createObject (
|
NodeObject::createObject (
|
||||||
NodeObjectType type,
|
NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
|
||||||
Blob&& data,
|
Blob&& data,
|
||||||
uint256 const& hash)
|
uint256 const& hash)
|
||||||
{
|
{
|
||||||
return std::make_shared <NodeObject> (
|
return std::make_shared <NodeObject> (
|
||||||
type, ledgerIndex, std::move (data), hash, PrivateAccess ());
|
type, std::move (data), hash, PrivateAccess ());
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeObjectType
|
NodeObjectType
|
||||||
@@ -61,12 +58,6 @@ NodeObject::getHash () const
|
|||||||
return mHash;
|
return mHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
LedgerIndex
|
|
||||||
NodeObject::getLedgerIndex () const
|
|
||||||
{
|
|
||||||
return mLedgerIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
Blob const&
|
Blob const&
|
||||||
NodeObject::getData () const
|
NodeObject::getData () const
|
||||||
{
|
{
|
||||||
@@ -82,9 +73,6 @@ NodeObject::isCloneOf (NodeObject::Ptr const& other) const
|
|||||||
if (mHash != other->mHash)
|
if (mHash != other->mHash)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mLedgerIndex != other->mLedgerIndex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mData != other->mData)
|
if (mData != other->mData)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ public:
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
LedgerIndex ledgerIndex = 1 + r.nextInt (1024 * 1024);
|
|
||||||
|
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
r.fillBitsRandomly (hash.begin (), hash.size ());
|
r.fillBitsRandomly (hash.begin (), hash.size ());
|
||||||
|
|
||||||
@@ -77,7 +75,7 @@ public:
|
|||||||
|
|
||||||
r.fillBitsRandomly (data.data (), payloadBytes);
|
r.fillBitsRandomly (data.data (), payloadBytes);
|
||||||
|
|
||||||
return NodeObject::createObject(type, ledgerIndex, std::move(data), hash);
|
return NodeObject::createObject(type, std::move(data), hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -176,7 +174,6 @@ public:
|
|||||||
Blob data (object->getData ());
|
Blob data (object->getData ());
|
||||||
|
|
||||||
db.store (object->getType (),
|
db.store (object->getType (),
|
||||||
object->getLedgerIndex (),
|
|
||||||
std::move (data),
|
std::move (data),
|
||||||
object->getHash ());
|
object->getHash ());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ private:
|
|||||||
|
|
||||||
beast::xor_shift_engine gen_;
|
beast::xor_shift_engine gen_;
|
||||||
std::uint8_t prefix_;
|
std::uint8_t prefix_;
|
||||||
std::uniform_int_distribution<std::uint32_t> d_seq_;
|
|
||||||
std::uniform_int_distribution<std::uint32_t> d_type_;
|
std::uniform_int_distribution<std::uint32_t> d_type_;
|
||||||
std::uniform_int_distribution<std::uint32_t> d_size_;
|
std::uniform_int_distribution<std::uint32_t> d_size_;
|
||||||
|
|
||||||
@@ -92,7 +91,6 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
Sequence(std::uint8_t prefix)
|
Sequence(std::uint8_t prefix)
|
||||||
: prefix_ (prefix)
|
: prefix_ (prefix)
|
||||||
, d_seq_ (minLedger, maxLedger)
|
|
||||||
, d_type_ (hotLEDGER, hotTRANSACTION_NODE)
|
, d_type_ (hotLEDGER, hotTRANSACTION_NODE)
|
||||||
, d_size_ (minSize, maxSize)
|
, d_size_ (minSize, maxSize)
|
||||||
{
|
{
|
||||||
@@ -122,7 +120,7 @@ public:
|
|||||||
rngcpy (&value[0], value.size(), gen_);
|
rngcpy (&value[0], value.size(), gen_);
|
||||||
return NodeObject::createObject (
|
return NodeObject::createObject (
|
||||||
static_cast<NodeObjectType>(d_type_(gen_)),
|
static_cast<NodeObjectType>(d_type_(gen_)),
|
||||||
d_seq_(gen_), std::move(value), key);
|
std::move(value), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a batch of NodeObjects starting at n
|
// returns a batch of NodeObjects starting at n
|
||||||
|
|||||||
@@ -1400,8 +1400,7 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMGetObjectByHash> const& m)
|
|||||||
if (obj.has_nodeid ())
|
if (obj.has_nodeid ())
|
||||||
newObj.set_index (obj.nodeid ());
|
newObj.set_index (obj.nodeid ());
|
||||||
|
|
||||||
if (!reply.has_seq () && (hObj->getLedgerIndex () != 0))
|
// VFALCO NOTE "seq" in the message is obsolete
|
||||||
reply.set_seq (hObj->getLedgerIndex ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -943,8 +943,8 @@ void SHAMap::writeNode (
|
|||||||
|
|
||||||
Serializer s;
|
Serializer s;
|
||||||
node->addRaw (s, snfPREFIX);
|
node->addRaw (s, snfPREFIX);
|
||||||
db_.store (t, seq,
|
db_.store (t, std::move (s.modData()),
|
||||||
std::move (s.modData ()), node->getNodeHash ());
|
node->getNodeHash ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't modify an inner node someone else might have a
|
// We can't modify an inner node someone else might have a
|
||||||
|
|||||||
Reference in New Issue
Block a user