Skip to content

Commit

Permalink
updating data wrapper properties
Browse files Browse the repository at this point in the history
Signed-off-by: instamenta <[email protected]>
  • Loading branch information
instamenta committed Dec 11, 2024
1 parent 1948c26 commit 3e3cdd9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/commands/node/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ export class NodeCommandTasks {
config.stagingDir,
);

// if directory data/upgrade/current/data/keys does not exist then use data/upgrade/current
// if directory data/upgrade/current/data/keys does not exist, then use data/upgrade/current
let keyDir = `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/data/keys`;
if (!(await self.k8.hasDir(nodeFullyQualifiedPodName, constants.ROOT_CONTAINER, keyDir))) {
keyDir = `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`;
Expand Down
14 changes: 8 additions & 6 deletions src/core/models/genesisNetworkDataConstructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {KeyManager} from '../key_manager.js';
import crypto from 'node:crypto';
import {PrivateKey} from '@hashgraph/sdk';
import * as constants from '../constants.js';
import * as x509 from '@peculiar/x509';

export class GenesisNetworkDataConstructor {
public readonly nodes: Record<NodeAlias, GenesisNetworkNodeDataWrapper>;
Expand All @@ -43,15 +44,16 @@ export class GenesisNetworkDataConstructor {
await Promise.all(this.nodeAliases.map(async nodeAlias => {
const nodeKeys = await keyManager.loadSigningKey(nodeAlias, keysDir);

this.nodes[nodeAlias].gossipCaCertificate = nodeKeys.certificate.toString()

const certificate = nodeKeys.certificate.toString();
const certPem = nodeKeys.certificate.toString()

// TODO: change parameters
const hash = crypto.createHash('sha256').update(certificate).digest('hex');
this.nodes[nodeAlias].gossipCaCertificate = certPem

this.nodes[nodeAlias].gossipCaCertificate = certificate;
this.nodes[nodeAlias].grpcCertificateHash = hash;
const tlsCertDer = new Uint8Array(x509.PemConverter.decode(certPem)[0]);

const grpcCertificateHash = crypto.createHash('sha384').update(tlsCertDer).digest();

this.nodes[nodeAlias].grpcCertificateHash = grpcCertificateHash.toString();
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/models/genesisNetworkNodeDataWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface Node {

export class GenesisNetworkNodeDataWrapper implements Node{
public readonly nodeId: number;
public readonly accountId: AccountId | string;
public accountId: AccountId | string;
public readonly description: string;
public gossipEndpoint: ServiceEndpoint;
public serviceEndpoint: ServiceEndpoint;
Expand Down
8 changes: 6 additions & 2 deletions src/core/profile_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,14 @@ export class ProfileManager {
const internalIP = Templates.renderFullyQualifiedNetworkPodName(namespace, nodeAlias);
const externalIP = Templates.renderFullyQualifiedNetworkSvcName(namespace, nodeAlias);

genesisNetworkData.nodes[nodeAlias].addGossipEndpoint(externalIP, +externalPort, '');
genesisNetworkData.nodes[nodeAlias].addServiceEndpoint(internalIP, +internalPort, '');
const nodeDataWrapper = genesisNetworkData.nodes[nodeAlias];
nodeDataWrapper.addGossipEndpoint(externalIP, +externalPort, '');
nodeDataWrapper.addServiceEndpoint(internalIP, +internalPort, '');

const account = nodeAccountMap.get(nodeAlias);

nodeDataWrapper.accountId = account

if (releaseVersion.minor >= 40) {
configLines.push(
`address, ${nodeSeq}, ${nodeSeq}, ${nodeAlias}, ${nodeStakeAmount}, ${internalIP}, ${internalPort}, ${externalIP}, ${externalPort}, ${account}`,
Expand Down

0 comments on commit 3e3cdd9

Please sign in to comment.