Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions backend/src/services/defaultChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ export class DefaultChecker {
return { signer, server, passphrase };
}

/**
* Fetches IDs of loans that are overdue based on the current ledger sequence.
* Queries the local database for active loans exceeding the term limit.
*/
private async fetchOverdueLoanIds(currentLedger: number): Promise<number[]> {
const result = await query(
`
Expand Down Expand Up @@ -194,6 +198,10 @@ export class DefaultChecker {
.filter((id: number) => Number.isInteger(id) && id > 0);
}

/**
* Calculates statistics for all currently overdue loans.
* Provides the total count and the age of the oldest overdue loan for monitoring.
*/
private async fetchOverdueStats(currentLedger: number): Promise<{
overdueCount: number;
oldestDueLedger?: number;
Expand Down Expand Up @@ -259,6 +267,10 @@ export class DefaultChecker {
};
}

/**
* Builds and submits a Soroban transaction to mark loans as defaulted.
* Invokes `check_defaults` on-chain; results in state changes and fee consumption.
*/
private async submitCheckDefaults(
server: rpc.Server,
signer: Keypair,
Expand Down Expand Up @@ -335,6 +347,10 @@ export class DefaultChecker {
};
}

/**
* Executes `submitCheckDefaults` with a maximum execution time limit.
* Ensures that slow Soroban RPC responses do not block the entire processing queue.
*/
private async submitCheckDefaultsWithTimeout(
server: rpc.Server,
signer: Keypair,
Expand Down
Loading