Skip to content

Commit

Permalink
fix(cactus-example-cbdc-bridging-backend): add missing CRPC port conf…
Browse files Browse the repository at this point in the history
…ig option

Signed-off-by: Christoph Orth <[email protected]>
  • Loading branch information
corthDfine authored and petermetz committed May 17, 2024
1 parent 8608ce7 commit 84c0733
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
5 changes: 4 additions & 1 deletion examples/cactus-example-cbdc-bridging-backend/process.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ API_HOST=localhost
API_SERVER_1_PORT=4000
API_SERVER_2_PORT=4100
API_HOST_FRONTEND=localhost
API_PORT_FRONTEND=2000
API_PORT_FRONTEND=2000
API_CRPC_HOST=localhost
API_SERVER_1_CRPC_PORT=6000
API_SERVER_2_CRPC_PORT=6100
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function launchApp(
exampleConfig.authorizationConfigJson,
) as unknown as IAuthorizationConfig;
exampleConfig.authorizationProtocol = AuthorizationProtocol.NONE;

const convictConfig =
await configService.newExampleConfigConvict(exampleConfig);

Expand Down Expand Up @@ -53,7 +53,10 @@ export async function launchApp(
if (
process.env.API_HOST == undefined ||
process.env.API_SERVER_1_PORT == undefined ||
process.env.API_SERVER_2_PORT == undefined
process.env.API_SERVER_2_PORT == undefined ||
process.env.API_CRPC_HOST == undefined ||
process.env.API_SERVER_1_CRPC_PORT == undefined ||
process.env.API_SERVER_2_CRPC_PORT == undefined
) {
throw new Error("Env variables not set");
}
Expand All @@ -65,6 +68,9 @@ export async function launchApp(
clientGatewayKeyPair: clientGatewayKeyPair,
serverGatewayKeyPair: serverGatewayKeyPair,
logLevel: "DEBUG",
apiCrpcHost: process.env.API_CRPC_HOST,
apiServer1CrpcPort: parseInt(process.env.API_SERVER_1_CRPC_PORT),
apiServer2CrpcPort: parseInt(process.env.API_SERVER_2_CRPC_PORT),
};

const cbdcBridgingApp = new CbdcBridgingApp(appOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ export interface ICbdcBridgingApp {
apiHost: string;
apiServer1Port: number;
apiServer2Port: number;
apiCrpcHost: string;
apiServer1CrpcPort: number;
apiServer2CrpcPort: number;
clientGatewayKeyPair: IKeyPair;
serverGatewayKeyPair: IKeyPair;
logLevel?: LogLevelDesc;
apiServerOptions?: ICactusApiServerOptions;
disableSignalHandlers?: true;
}

interface ICrpcOptions {
host: string;
port: number;
}

export type ShutdownHook = () => Promise<void>;
export class CbdcBridgingApp {
private readonly log: Logger;
Expand Down Expand Up @@ -101,12 +109,11 @@ export class CbdcBridgingApp {
nodeApiHostA,
this.options.clientGatewayKeyPair,
);

const besuSatpGateway = await this.infrastructure.createServerGateway(
nodeApiHostB,
this.options.serverGatewayKeyPair,
);

const clientPluginRegistry = new PluginRegistry({
plugins: [
new PluginKeychainMemory({
Expand All @@ -125,15 +132,18 @@ export class CbdcBridgingApp {
}),
],
});

clientPluginRegistry.add(fabricPlugin);
clientPluginRegistry.add(fabricSatpGateway);

serverPluginRegistry.add(besuPlugin);
serverPluginRegistry.add(besuSatpGateway);

const apiServer1 = await this.startNode(httpApiA, clientPluginRegistry);
const apiServer2 = await this.startNode(httpApiB, serverPluginRegistry);
const crpcOptionsServer1 = {host: this.options.apiCrpcHost, port: this.options.apiServer1CrpcPort};
const apiServer1 = await this.startNode(httpApiA, clientPluginRegistry, crpcOptionsServer1);

const crpcOptionsServer2 = {host: this.options.apiCrpcHost, port: this.options.apiServer2CrpcPort};
const apiServer2 = await this.startNode(httpApiB, serverPluginRegistry, crpcOptionsServer2);

const fabricApiClient = new FabricApi(
new Configuration({ basePath: nodeApiHostA }),
Expand Down Expand Up @@ -184,6 +194,7 @@ export class CbdcBridgingApp {
public async startNode(
httpServerApi: Server,
pluginRegistry: PluginRegistry,
crpcOptions: ICrpcOptions,
): Promise<ApiServer> {
this.log.info(`Starting API Server node...`);

Expand All @@ -204,6 +215,8 @@ export class CbdcBridgingApp {
config.grpcPort = 0;
config.logLevel = this.options.logLevel || "INFO";
config.authorizationProtocol = AuthorizationProtocol.NONE;
config.crpcHost = crpcOptions.host;
config.crpcPort = crpcOptions.port;
}

const apiServer = new ApiServer({
Expand Down

0 comments on commit 84c0733

Please sign in to comment.