Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix too big policy #2380

Merged
merged 1 commit into from
Jul 5, 2023
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
1 change: 0 additions & 1 deletion guardian-service/src/policy-engine/policy-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,6 @@ export class PolicyEngine extends NatsService {

try {
const r = await this.sendMessageWithTimeout<any>(PolicyEvents.GENERATE_POLICY, 1000, {
policy,
policyId,
skipRegistration: false
});
Expand Down
11 changes: 6 additions & 5 deletions policy-service/src/api/policy-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { GridFSBucket } from 'mongodb';
import { SynchronizationService } from '@policy-engine/multi-policy-service';

const {
policy,
policyId,
policyServiceName,
skipRegistration
Expand All @@ -37,14 +36,17 @@ Promise.all([
Environment.setLocalNodeProtocol(process.env.LOCALNODE_PROTOCOL);
Environment.setLocalNodeAddress(process.env.LOCALNODE_ADDRESS);
Environment.setNetwork(process.env.HEDERA_NET);

const policyConfig = await DatabaseServer.getPolicyById(policyId);

if (process.env.HEDERA_CUSTOM_NODES) {
try {
const nodes = JSON.parse(process.env.HEDERA_CUSTOM_NODES);
Environment.setNodes(nodes);
} catch (error) {
await new Logger().warn(
'HEDERA_CUSTOM_NODES field in settings: ' + error.message,
['POLICY', policy.name, policyId.toString()]
['POLICY', policyConfig.name, policyId.toString()]
);
console.warn(error);
}
Expand All @@ -59,7 +61,7 @@ Promise.all([
await new Logger().warn(
'HEDERA_CUSTOM_MIRROR_NODES field in settings: ' +
error.message,
['POLICY', policy.name, policyId.toString()]
['POLICY', policyConfig.name, policyId.toString()]
);
console.warn(error);
}
Expand All @@ -81,7 +83,6 @@ Promise.all([

new Logger().info(`Process for with id ${policyId} was started started PID: ${process.pid}`, ['POLICY', policyId]);

const policyConfig = await DatabaseServer.getPolicyById(policyId);
const generator = new BlockTreeGenerator();
const policyValidator = new PolicyValidator(policyConfig);

Expand All @@ -105,5 +106,5 @@ Promise.all([
new LargePayloadContainer().runServer();
}

new Logger().info('Start policy', ['POLICY', policy.name, policyId.toString()]);
new Logger().info('Start policy', ['POLICY', policyConfig.name, policyId.toString()]);
});
7 changes: 0 additions & 7 deletions policy-service/src/helpers/policy-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import { POLICY_PROCESS_PATH } from '@api/policy-process-path';
* Policy start options
*/
export interface IPolicyStartOptions {
/**
* Config
*/
policy: unknown;

/**
* Service name
*/
Expand Down Expand Up @@ -304,15 +299,13 @@ export class PolicyContainer extends NatsService {
}

const {
policy,
policyId,
policyServiceName,
skipRegistration
} = instance.options;

const childEnvironment = Object.assign(process.env, {
POLICY_START_OPTIONS: JSON.stringify({
policy,
policyId,
policyServiceName,
skipRegistration
Expand Down