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 5f876cf commit f82403c
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 123 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: 15 additions & 18 deletions sdk/src/accounts/webSocketAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,23 @@ 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`
);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.accountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`
);
}
},
this.resubOpts?.resubTimeoutMs
);
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
}, this.resubOpts?.resubTimeoutMs);
}

async fetch(): Promise<void> {
Expand Down
33 changes: 15 additions & 18 deletions sdk/src/accounts/webSocketProgramAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,23 @@ 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`
);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.subscriptionName} in ${this.resubOpts?.resubTimeoutMs}ms, resubscribing`
);
}
},
this.resubOpts?.resubTimeoutMs
);
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
}, this.resubOpts?.resubTimeoutMs);
}

handleRpcResponse(
Expand Down
10 changes: 6 additions & 4 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3936,8 +3936,9 @@ 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 @@ -4155,8 +4156,9 @@ 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 f82403c

Please sign in to comment.