Skip to content

Commit

Permalink
feat: retry da balances (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasDeco authored and kilgaloon committed Aug 6, 2024
1 parent ce604d1 commit 375ef42
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/client/rpc/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FutarchyBalancesClient } from "@/client";
import { PublicKey } from "@solana/web3.js";
import { Proposal } from "@/types/proposals";
import { BN, Provider } from "@coral-xyz/anchor";
import { Observable } from "rxjs";
import { Observable, retry } from "rxjs";

export class FutarchyRPCBalancesClient implements FutarchyBalancesClient {
private rpcProvider: Provider;
Expand Down Expand Up @@ -126,7 +126,7 @@ export class FutarchyRPCBalancesClient implements FutarchyBalancesClient {
public watchTokenBalance(
tokenWithPDA: TokenWithPDA
): Observable<TokenWithBalance> {
return new Observable((subscriber) => {
const obs = new Observable<TokenWithBalance>((subscriber) => {
// yield initial fetch
this.rpcProvider.connection
.getTokenAccountBalance(tokenWithPDA.pda)
Expand Down Expand Up @@ -158,6 +158,13 @@ export class FutarchyRPCBalancesClient implements FutarchyBalancesClient {

return () => subscriber.complete();
});

return obs.pipe<TokenWithBalance>(
retry({
count: 100,
delay: 5_000
})
);
}

/**
Expand Down

0 comments on commit 375ef42

Please sign in to comment.