@@ -1321,25 +1321,36 @@ export class StellarSplitClient {
13211321 */
13221322 async getInvoice (
13231323 invoiceId : string ,
1324+ opts ?: { retry ?: PerMethodRetryOptions ; dedupe ?: boolean }
13241325 opts ?: { retry ?: PerMethodRetryOptions ; traceId ?: string; timeout ? : number }
13251326 ) : Promise < Invoice > {
13261327 return this . _withCache ( "getInvoice" , [ invoiceId ] , async ( ) => {
13271328 const fetcher = this . _batcher
13281329 ? ( ) => this . _batcher ! . getInvoice ( invoiceId )
13291330 : ( ) => this . _fetchInvoice ( invoiceId , opts ?. traceId ) ;
13301331
1332+ const useDedupe = opts ?. dedupe !== false ;
13311333 const effectiveRetry = opts ?. retry ?? ( this . _retryOptions ? { } : undefined ) ;
13321334 if ( this . _retryOptions && effectiveRetry !== undefined ) {
13331335 return await executeWithRetry (
1334- ( ) => this . _dedup . dedupe ( invoiceId , fetcher ) ,
1336+ ( ) => useDedupe ? this . _dedup . dedupe ( invoiceId , fetcher ) : fetcher ( ) ,
13351337 this . _retryOptions ,
13361338 opts ?. retry
13371339 ) ;
13381340 }
1339- return await this . _dedup . dedupe ( invoiceId , fetcher ) ;
1341+ return useDedupe ? this . _dedup . dedupe ( invoiceId , fetcher ) : fetcher ( ) ;
13401342 } ) ;
13411343 }
13421344
1345+ /**
1346+ * Returns deduplication statistics for observability.
1347+ * @returns { deduped: number, total: number } — deduped is how many calls were short-circuited.
1348+ */
1349+ getDedupStats ( ) : { deduped: number ; total: number } {
1350+ return this . _dedup . getDedupStats ( ) ;
1351+ }
1352+
1353+ private async _fetchInvoice ( invoiceId : string) : Promise < Invoice > {
13431354 private async _fetchInvoice ( invoiceId : string , traceId ?: string ) : Promise < Invoice > {
13441355 const startTime = Date . now ( ) ;
13451356 const req = { method : "getInvoice" , params : [ invoiceId ] , headers : traceId ? { "X-Trace-Id" : traceId } : undefined } ;
0 commit comments