-
Notifications
You must be signed in to change notification settings - Fork 1.7k
refactor: Use ApplyViewContext everywhere instead of ApplyView+STTx #7618
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
base: xrplf/sponsor
Are you sure you want to change the base?
Changes from all commits
b6e1b33
20eaf5c
1a2a7e9
88ae2bb
bcb3de1
00fc081
7644970
6947d41
b591bfe
02cc200
d73340e
759bd45
bf4fa8e
0864dfc
2759dfb
9485c3c
aee7651
4a3a247
c710a8a
b8ae7a2
f005879
13aff69
ad4abab
4395da1
8f470b7
c7a3abb
4cbc050
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,7 @@ namespace xrpl { | |
| template <ValidIssueType T> | ||
| TER | ||
| escrowUnlockApplyHelper( | ||
| ApplyView& view, | ||
| STTx const& tx, | ||
| ApplyViewContext const& ctx, | ||
| Rate lockedRate, | ||
| SLE::ref sleDest, | ||
| STAmount const& xrpBalance, | ||
|
|
@@ -32,8 +31,7 @@ escrowUnlockApplyHelper( | |
| template <> | ||
| inline TER | ||
| escrowUnlockApplyHelper<Issue>( | ||
| ApplyView& view, | ||
| STTx const& tx, | ||
| ApplyViewContext const& ctx, | ||
| Rate lockedRate, | ||
| SLE::ref sleDest, | ||
| STAmount const& xrpBalance, | ||
|
|
@@ -49,6 +47,7 @@ escrowUnlockApplyHelper<Issue>( | |
| bool const recvLow = issuer > receiver; | ||
| bool const senderIssuer = issuer == sender; | ||
| bool const receiverIssuer = issuer == receiver; | ||
| auto& view = ctx.view; | ||
|
|
||
| if (senderIssuer) | ||
| return tecINTERNAL; // LCOV_EXCL_LINE | ||
|
|
@@ -59,12 +58,12 @@ escrowUnlockApplyHelper<Issue>( | |
| if (!view.exists(trustLineKey) && createAsset) | ||
| { | ||
| // Can the account cover the trust line's reserve? | ||
| auto const sponsorSle = getTxReserveSponsor(view, tx); | ||
| auto const sponsorSle = getTxReserveSponsor({.view = ctx.view, .tx = ctx.tx}); | ||
| if (!sponsorSle) | ||
| return sponsorSle.error(); // LCOV_EXCL_LINE | ||
|
|
||
| if (auto const ret = | ||
| checkInsufficientReserve(view, tx, sleDest, xrpBalance, *sponsorSle, 1, 0, journal); | ||
| if (auto const ret = checkInsufficientReserve( | ||
| view, ctx.tx, sleDest, xrpBalance, *sponsorSle, 1, 0, journal); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this should be changed too, like getTxReserveSponsor
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, agreed. However, we can't do that in this PR - it currently takes a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| !isTesSuccess(ret)) | ||
| { | ||
| JLOG(journal.trace()) << "Trust line does not exist. " | ||
|
|
@@ -169,8 +168,7 @@ escrowUnlockApplyHelper<Issue>( | |
| template <> | ||
| inline TER | ||
| escrowUnlockApplyHelper<MPTIssue>( | ||
| ApplyView& view, | ||
| STTx const& tx, | ||
| ApplyViewContext const& ctx, | ||
| Rate lockedRate, | ||
| SLE::ref sleDest, | ||
| STAmount const& xrpBalance, | ||
|
|
@@ -183,18 +181,19 @@ escrowUnlockApplyHelper<MPTIssue>( | |
| { | ||
| bool const senderIssuer = issuer == sender; | ||
| bool const receiverIssuer = issuer == receiver; | ||
| auto& view = ctx.view; | ||
|
|
||
| auto const mptID = amount.get<MPTIssue>().getMptID(); | ||
| auto const issuanceKey = keylet::mptIssuance(mptID); | ||
| auto const mptKeylet = keylet::mptoken(issuanceKey.key, receiver); | ||
| if (!view.exists(mptKeylet) && createAsset && !receiverIssuer) | ||
| { | ||
| auto const sponsorSle = getTxReserveSponsor(view, tx); | ||
| auto const sponsorSle = getTxReserveSponsor({.view = ctx.view, .tx = ctx.tx}); | ||
| if (!sponsorSle) | ||
| return sponsorSle.error(); // LCOV_EXCL_LINE | ||
|
|
||
| if (auto const ret = | ||
| checkInsufficientReserve(view, tx, sleDest, xrpBalance, *sponsorSle, 1, 0, journal); | ||
| if (auto const ret = checkInsufficientReserve( | ||
| view, ctx.tx, sleDest, xrpBalance, *sponsorSle, 1, 0, journal); | ||
| !isTesSuccess(ret)) | ||
| return ret; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should disable copy constructors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9485c3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this, it doesn't work because we're passing by value not reference so we are copying
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to disable copy constructors and pass it by right reference, or forgotten copy can appear somewhere