mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 15:05:53 +00:00
Refactor and improve the SHAMap code:
This commit combines a number of cleanups, targeting both the code structure and the code logic. Large changes include: - Using more strongly-typed classes for SHAMap nodes, instead of relying on runtime-time detection of class types. This change saves 16 bytes of memory per node. - Improving the interface of SHAMap::addGiveItem and SHAMap::addItem to avoid the need for passing two bool arguments. - Documenting the "copy-on-write" semantics that SHAMap uses to efficiently track changes in individual nodes. - Removing unused code and simplifying several APIs. - Improving function naming.
This commit is contained in:
@@ -405,11 +405,11 @@ Shard::storeLedger(
|
||||
}
|
||||
|
||||
bool error = false;
|
||||
auto visit = [&](SHAMapAbstractNode& node) {
|
||||
auto visit = [&](SHAMapTreeNode const& node) {
|
||||
if (!stop_)
|
||||
{
|
||||
if (auto nodeObject = srcDB.fetchNodeObject(
|
||||
node.getNodeHash().as_uint256(), srcLedger->info().seq))
|
||||
node.getHash().as_uint256(), srcLedger->info().seq))
|
||||
{
|
||||
batch.emplace_back(std::move(nodeObject));
|
||||
if (batch.size() < batchWritePreallocationSize || storeBatch())
|
||||
@@ -1288,10 +1288,10 @@ Shard::verifyLedger(
|
||||
return fail("Invalid ledger account hash");
|
||||
|
||||
bool error{false};
|
||||
auto visit = [this, &error](SHAMapAbstractNode& node) {
|
||||
auto visit = [this, &error](SHAMapTreeNode const& node) {
|
||||
if (stop_)
|
||||
return false;
|
||||
if (!verifyFetch(node.getNodeHash().as_uint256()))
|
||||
if (!verifyFetch(node.getHash().as_uint256()))
|
||||
error = true;
|
||||
return !error;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user