Skip to content

Commit

Permalink
Prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecaan committed Jan 3, 2025
1 parent f82403c commit 2b2330c
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 113 deletions.
2 changes: 1 addition & 1 deletion sdk/src/accounts/grpcProgramAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../isomorphic/grpc';

export class grpcProgramAccountSubscriber<
T
T,
> extends WebSocketProgramAccountSubscriber<T> {
client: Client;
stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
Expand Down
33 changes: 18 additions & 15 deletions sdk/src/accounts/webSocketAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,26 @@ export class WebSocketAccountSubscriber<T> implements AccountSubscriber<T> {
if (!this.onChange) {
throw new Error('onChange callback function must be set');
}
this.timeoutId = setTimeout(async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}
this.timeoutId = setTimeout(
async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}

if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.accountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`
);
if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.accountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`
);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
}, this.resubOpts?.resubTimeoutMs);
},
this.resubOpts?.resubTimeoutMs
);
}

async fetch(): Promise<void> {
Expand Down
33 changes: 18 additions & 15 deletions sdk/src/accounts/webSocketProgramAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,26 @@ export class WebSocketProgramAccountSubscriber<T>
if (!this.onChange) {
throw new Error('onChange callback function must be set');
}
this.timeoutId = setTimeout(async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}
this.timeoutId = setTimeout(
async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}

if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.subscriptionName} in ${this.resubOpts?.resubTimeoutMs}ms, resubscribing`
);
if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.subscriptionName} in ${this.resubOpts?.resubTimeoutMs}ms, resubscribing`
);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
}, this.resubOpts?.resubTimeoutMs);
},
this.resubOpts?.resubTimeoutMs
);
}

handleRpcResponse(
Expand Down
10 changes: 4 additions & 6 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3936,9 +3936,8 @@ export class DriftClient {
subAccountId?: number
): Promise<TransactionSignature> {
const { txSig } = await this.sendTransaction(
(
await this.preparePlaceOrdersTx(params, txParams, subAccountId)
).placeOrdersTx,
(await this.preparePlaceOrdersTx(params, txParams, subAccountId))
.placeOrdersTx,
[],
this.opts,
false
Expand Down Expand Up @@ -4156,9 +4155,8 @@ export class DriftClient {
subAccountId?: number
): Promise<TransactionSignature> {
const { txSig, slot } = await this.sendTransaction(
(
await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId)
).placeSpotOrderTx,
(await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId))
.placeSpotOrderTx,
[],
this.opts,
false
Expand Down
Loading

0 comments on commit 2b2330c

Please sign in to comment.