diff --git a/libraries/fabric-shim/lib/chaincode.js b/libraries/fabric-shim/lib/chaincode.js
index 39552cddb..65c1fc78f 100644
--- a/libraries/fabric-shim/lib/chaincode.js
+++ b/libraries/fabric-shim/lib/chaincode.js
@@ -199,6 +199,11 @@ class Shim {
return Logger.getLogger(name);
}
+ /**
+ * @interface GRPCOptions
+ * @description ChannelOptions on "@grpc/grpc-js". For a complete list, refer to @grpc/grpc-js Documentation
+ * @property {unknown[]} ['grpc.${string}'] Connection options defined on "@grpc/grpc-js"
+ */
/**
* @interface ChaincodeServerTLSProperties
* @property {Buffer} key Private key for TLS
@@ -207,6 +212,7 @@ class Shim {
*/
/**
* @interface ChaincodeServerOpts
+ * @extends GRPCOptions
* @property {string} ccid Chaincode ID
* @property {string} address Listen address for the server
* @property {ChaincodeServerTLSProperties} [tlsProps] TLS properties if TLS is required.
diff --git a/libraries/fabric-shim/lib/server.js b/libraries/fabric-shim/lib/server.js
index f075086a9..9d6336b6d 100644
--- a/libraries/fabric-shim/lib/server.js
+++ b/libraries/fabric-shim/lib/server.js
@@ -58,8 +58,12 @@ class ChaincodeServer {
this._credentials = grpc.ServerCredentials.createInsecure();
}
+ const grpcOptions = Object.fromEntries(
+ Object.entries(serverOpts).filter(([key]) => key.startsWith('grpc.'))
+ );
+
// Create GRPC Server and register RPC handler
- this._server = new grpc.Server();
+ this._server = new grpc.Server(grpcOptions);
this._server.addService(peer.ChaincodeService, this);
this._serverOpts = serverOpts;
diff --git a/libraries/fabric-shim/types/index.d.ts b/libraries/fabric-shim/types/index.d.ts
index 2ebf37c70..2e948ceff 100644
--- a/libraries/fabric-shim/types/index.d.ts
+++ b/libraries/fabric-shim/types/index.d.ts
@@ -6,8 +6,8 @@
*/
declare module 'fabric-shim' {
- import { EventEmitter } from 'events';
import { Logger } from 'winston';
+ import { ChannelOptions } from '@grpc/grpc-js'
import {
ChaincodeInterface,
@@ -53,7 +53,11 @@ declare module 'fabric-shim' {
start(): Promise;
}
- export interface ChaincodeServerOpts {
+ type GRPCOptions = {
+ [K in keyof ChannelOptions as string extends K ? never : K]?: ChannelOptions[K];
+ }
+
+ export interface ChaincodeServerOpts extends GRPCOptions {
ccid: string;
address: string;
tlsProps: ChaincodeServerTLSProperties;
@@ -140,7 +144,7 @@ declare module 'fabric-shim' {
constructor(policy?: Uint8Array);
getPolicy(): Uint8Array;
addOrgs(role: string, ...newOrgs: string[]): void;
- delOrgs(...delOrgs: string[]):void;
+ delOrgs(...delOrgs: string[]): void;
listOrgs(): string[];
}