mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Compare commits
1 Commits
bthomee/lo
...
ximinez/nu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b19387d84b |
@@ -229,6 +229,19 @@ public:
|
||||
std::shared_ptr<Serializer const> const& txn,
|
||||
std::shared_ptr<Serializer const> const& metaData) override;
|
||||
|
||||
// Insert the transaction, and return the hash of the SHAMap leaf node
|
||||
// holding the transaction. The hash can be used to fetch the transaction
|
||||
// directly, instead of traversing the SHAMap
|
||||
// @param key transaction ID
|
||||
// @param txn transaction
|
||||
// @param metaData transaction metadata
|
||||
// @return hash of SHAMap leaf node that holds the transaction
|
||||
uint256
|
||||
rawTxInsertWithHash(
|
||||
uint256 const& key,
|
||||
std::shared_ptr<Serializer const> const& txn,
|
||||
std::shared_ptr<Serializer const> const& metaData);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <xrpl/nodestore/NodeObject.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/HashPrefix.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/KeyType.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <xrpl/protocol/Seed.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
#include <xrpl/protocol/SystemParameters.h>
|
||||
#include <xrpl/protocol/digest.h>
|
||||
#include <xrpl/shamap/Family.h>
|
||||
#include <xrpl/shamap/SHAMap.h>
|
||||
#include <xrpl/shamap/SHAMapItem.h>
|
||||
@@ -41,6 +43,7 @@
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -490,14 +493,14 @@ void
|
||||
Ledger::rawErase(std::shared_ptr<SLE> const& sle)
|
||||
{
|
||||
if (!stateMap_.delItem(sle->key()))
|
||||
LogicError("Ledger::rawErase: key not found");
|
||||
Throw<std::logic_error>("Ledger::rawErase: key not found");
|
||||
}
|
||||
|
||||
void
|
||||
Ledger::rawErase(uint256 const& key)
|
||||
{
|
||||
if (!stateMap_.delItem(key))
|
||||
LogicError("Ledger::rawErase: key not found");
|
||||
Throw<std::logic_error>("Ledger::rawErase: key not found");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -507,7 +510,7 @@ Ledger::rawInsert(std::shared_ptr<SLE> const& sle)
|
||||
sle->add(ss);
|
||||
if (!stateMap_.addGiveItem(
|
||||
SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice())))
|
||||
LogicError("Ledger::rawInsert: key already exists");
|
||||
Throw<std::logic_error>("Ledger::rawInsert: key already exists");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -517,7 +520,7 @@ Ledger::rawReplace(std::shared_ptr<SLE> const& sle)
|
||||
sle->add(ss);
|
||||
if (!stateMap_.updateGiveItem(
|
||||
SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice())))
|
||||
LogicError("Ledger::rawReplace: key not found");
|
||||
Throw<std::logic_error>("Ledger::rawReplace: key not found");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -533,7 +536,27 @@ Ledger::rawTxInsert(
|
||||
s.addVL(txn->peekData());
|
||||
s.addVL(metaData->peekData());
|
||||
if (!txMap_.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, make_shamapitem(key, s.slice())))
|
||||
LogicError("duplicate_tx: " + to_string(key));
|
||||
Throw<std::logic_error>("duplicate_tx: " + to_string(key));
|
||||
}
|
||||
|
||||
uint256
|
||||
Ledger::rawTxInsertWithHash(
|
||||
uint256 const& key,
|
||||
std::shared_ptr<Serializer const> const& txn,
|
||||
std::shared_ptr<Serializer const> const& metaData)
|
||||
{
|
||||
XRPL_ASSERT(metaData, "xrpl::Ledger::rawTxInsertWithHash : non-null metadata input");
|
||||
|
||||
// low-level - just add to table
|
||||
Serializer s(txn->getDataLength() + metaData->getDataLength() + 16);
|
||||
s.addVL(txn->peekData());
|
||||
s.addVL(metaData->peekData());
|
||||
auto item = make_shamapitem(key, s.slice());
|
||||
auto hash = sha512Half(HashPrefix::txNode, item->slice(), item->key());
|
||||
if (!txMap_.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, std::move(item)))
|
||||
Throw<std::logic_error>("duplicate_tx: " + to_string(key));
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -1581,6 +1581,30 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class NumberPerf_test : public Number_test
|
||||
{
|
||||
void
|
||||
run() override
|
||||
{
|
||||
// This suite will give the most accurate results when run
|
||||
// single threaded, suppressing non-log output.
|
||||
// "--unittest=NumberPerf --quiet --unittest-log"
|
||||
using clock_type = std::chrono::steady_clock;
|
||||
|
||||
int limit = 100000;
|
||||
auto const start = clock_type::now();
|
||||
for (int i = 0; i < limit; ++i)
|
||||
{
|
||||
Number_test::run();
|
||||
}
|
||||
auto const duration =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(clock_type::now() - start);
|
||||
|
||||
log << "Number test repeated " << limit << " times took " << duration << "\n";
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Number, basics, xrpl);
|
||||
BEAST_DEFINE_TESTSUITE_MANUAL(NumberPerf, tx, xrpl);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
Reference in New Issue
Block a user