Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace dirAdd() calls with dirAppend() or dirInsert() #3830

Closed
wants to merge 2 commits into from

Conversation

scottschurr
Copy link
Collaborator

@scottschurr scottschurr commented Apr 22, 2021

High Level Overview of Change

Just tidying up some unfinished business here: #2516

Calls to dirDelete() had been removed in a previous commit. Now that the SortedDirectories amendment is unconditionally enabled, it's okay to remove the calls to dirAdd(). Once all dirAdd() calls are removed, then dirAdd() itself can be removed. That's what we do here.

Type of Change

  • Refactor (non-breaking change that only restructures code)

This change is purely a refactor and should have no effect on functionality. So the change should not need any mention in the release notes.

"Call dirInsert() instead.");
return std::nullopt;
}
return dirAdd(true, directory, key.key, describe);
Copy link
Collaborator

@gregtatcam gregtatcam Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "High Level Overview of Change" in the PR threw me off at first since it says "remove the calls to dirAdd()". Perhaps it should clarify what "dirAdd()" should be deleted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the assert to try to keep us from doing anything weird, but I'm not sure it's a good idea. This function is intended to append to the particular directory, instead of trying to fit it into the first page with an empty slot. It's true that this operation is currently only used by order books (so as to maintain temporal ordering of offers), but there's nothing that prevents this from being used differently, so I think the assert my communicate the wrong information.

For example, imagine if we added a new directory for, say, NFT offers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At @nbougalis, I think the assert is a good idea because it helps keep folks less familiar with the code on the straight and narrow. To someone who is not intimate with this code, it may not be obvious whether a particular object should be added or appended to the directory. As it stands there's currently only one situation where append is appropriate: offers in book directories. All other cases use add.

In the future there may, indeed, be other situations where appending is the right thing to do. But the source code is malleable, so the assert can be removed or changed when the new situation arises.

Just my take...

Copy link
Collaborator

@gregtatcam gregtatcam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@@ -186,7 +186,8 @@ CreateCheck::doApply()
// Note that we we use the value from the sequence or ticket as the
// Check sequence. For more explanation see comments in SeqProxy.h.
std::uint32_t const seq = ctx_.tx.getSeqProxy().value();
auto sleCheck = std::make_shared<SLE>(keylet::check(account_, seq));
Keylet const checkKeylet = keylet::check(account_, seq);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are in the neighborhood, please correct the comment by removing the extra 'we'.

describeOwnerDir(dstAccountId),
viewJ);
checkKeylet,
describeOwnerDir(dstAccountId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it may be worth replacing sleCheck->key() in the log calls below with the new local checkKeylet.key.

describeOwnerDir(account_),
viewJ);
ticketKeylet,
describeOwnerDir(account_));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it may be worth replacing sleTicket->key() in the log call below with the new local ticketKeylet.key.

Copy link
Contributor

@miguelportilla miguelportilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@scottschurr
Copy link
Collaborator Author

@miguelportilla, thanks for the careful review. I made your suggested changes in this commit: c2a3b9f Let me know if you're good with those changes. If you are, and the branch passes CI, then I'll squash and mark the pull request as passed. Thanks.

"Call dirInsert() instead.");
return std::nullopt;
}
return dirAdd(true, directory, key.key, describe);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the assert to try to keep us from doing anything weird, but I'm not sure it's a good idea. This function is intended to append to the particular directory, instead of trying to fit it into the first page with an empty slot. It's true that this operation is currently only used by order books (so as to maintain temporal ordering of offers), but there's nothing that prevents this from being used differently, so I think the assert my communicate the wrong information.

For example, imagine if we added a new directory for, say, NFT offers.

@miguelportilla
Copy link
Contributor

@scottschurr Changes look great, thank you.

@scottschurr scottschurr added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label May 24, 2021
This was referenced Jun 2, 2021
@scottschurr scottschurr deleted the rm-dir-add branch June 4, 2021 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants