Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 2 additions & 28 deletions sdk/src/accounts/grpcAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
private stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
private commitmentLevel: CommitmentLevel;
public listenerId?: number;
private enableReconnect: boolean;

private constructor(
client: Client,
Expand All @@ -27,13 +26,11 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
program: Program,
accountPublicKey: PublicKey,
decodeBuffer?: (buffer: Buffer) => T,
resubOpts?: ResubOpts,
enableReconnect = false
resubOpts?: ResubOpts
) {
super(accountName, program, accountPublicKey, decodeBuffer, resubOpts);
this.client = client;
this.commitmentLevel = commitmentLevel;
this.enableReconnect = enableReconnect;
}

public static async create<U>(
Expand All @@ -60,8 +57,7 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
program,
accountPublicKey,
decodeBuffer,
resubOpts,
grpcConfigs.enableReconnect
resubOpts
);
}

Expand Down Expand Up @@ -95,26 +91,6 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
entry: {},
transactionsStatus: {},
};

if (this.enableReconnect) {
this.stream.on('error', (error) => {
// @ts-ignore
if (error.code === 1) {
// expected: 1 CANCELLED: Cancelled on client
console.error(
'GRPC (grpcAccountSubscriber) Cancelled on client caught:',
error
);
return;
} else {
console.error(
'GRPC (grpcAccountSubscriber) unexpected error caught:',
error
);
}
});
}

this.stream.on('data', (chunk: SubscribeUpdate) => {
if (!chunk.account) {
return;
Expand Down Expand Up @@ -196,8 +172,6 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
reject(err);
}
});
this.stream.cancel();
this.stream.destroy();
}).catch((reason) => {
console.error(reason);
throw reason;
Expand Down
30 changes: 2 additions & 28 deletions sdk/src/accounts/grpcProgramAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class grpcProgramAccountSubscriber<
private stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
private commitmentLevel: CommitmentLevel;
public listenerId?: number;
private enableReconnect: boolean;

private constructor(
client: Client,
Expand All @@ -32,8 +31,7 @@ export class grpcProgramAccountSubscriber<
options: { filters: MemcmpFilter[] } = {
filters: [],
},
resubOpts?: ResubOpts,
enableReconnect = false
resubOpts?: ResubOpts
) {
super(
subscriptionName,
Expand All @@ -45,7 +43,6 @@ export class grpcProgramAccountSubscriber<
);
this.client = client;
this.commitmentLevel = commitmentLevel;
this.enableReconnect = enableReconnect;
}

public static async create<U>(
Expand Down Expand Up @@ -76,8 +73,7 @@ export class grpcProgramAccountSubscriber<
program,
decodeBufferFn,
options,
resubOpts,
grpcConfigs.enableReconnect
resubOpts
);
}

Expand Down Expand Up @@ -123,26 +119,6 @@ export class grpcProgramAccountSubscriber<
entry: {},
transactionsStatus: {},
};

if (this.enableReconnect) {
this.stream.on('error', (error) => {
// @ts-ignore
if (error.code === 1) {
// expected: 1 CANCELLED: Cancelled on client
console.error(
'GRPC (grpcProgramAccountSubscriber) Cancelled on client caught:',
error
);
return;
} else {
console.error(
'GRPC (grpcProgramAccountSubscriber) unexpected error caught:',
error
);
}
});
}

this.stream.on('data', (chunk: SubscribeUpdate) => {
if (!chunk.account) {
return;
Expand Down Expand Up @@ -230,8 +206,6 @@ export class grpcProgramAccountSubscriber<
reject(err);
}
});
this.stream.cancel();
this.stream.destroy();
}).catch((reason) => {
console.error(reason);
throw reason;
Expand Down
Loading