Implemeted lightweight loan-status view#35
Conversation
ogazboiz
left a comment
There was a problem hiding this comment.
the view itself is good: get_loan_status is properly read-only (reads the loan, bumps ttl only, no accrual or set), returns the right status, and handles missing loans without panicking (LoanNotFound, and get_borrower_loans_by_status skips absent ids). the status coverage in the tests is thorough.
two blockers though:
-
it clobbers #32, which just merged. your branch was built against an older main and put get_loan_status in the exact spot where #32 added
pub fn quote_total_debt. github auto-merges this without a conflict marker, but the merged result silently deletes quote_total_debt (there's only a dangling doc-comment referencing it left at lib.rs:1150). that reverts #32. please rebase on current main (git fetch origin && git rebase origin/main && git push --force-with-lease) and add get_loan_status as a new function alongside quote_total_debt, fixing the now-dangling doc reference. -
ci is red on cargo fmt:
loan_manager/src/test.rs:1701(a let binding written with no indentation) andloan_manager/src/lib.rs:2070(the get_borrower_loans_by_status signature wants splitting across lines). runcargo fmtand push.
once it's rebased so quote_total_debt survives and fmt is green, i'll re-review.
if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
Summary
Add lightweight loan status view methods to reduce the need for full loan lookups and avoid triggering accrual logic during read-only operations.
Changes
get_loan_status(loan_id)to return the storedLoanStatuswithout running accrual.Why
The contract currently exposes:
get_loanget_borrower_loansget_total_loansHowever, there is no lightweight way to:
As a result, consumers must call
get_loanfor every loan ID, which can be expensive and may introduce side effects through accrual calculations.The new view methods provide a cheaper and safer way to inspect loan state.
Acceptance Criteria
get_loan_status(loan_id)returning the storedLoanStatus.Files Changed
loan_manager/src/lib.rsOut of Scope
Closes #19