Skip to content

Commit

Permalink
fixes for #339
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Feb 28, 2022
1 parent 2523d70 commit af5cd57
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/agent/service/vaultsScan.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import type * as grpc from '@grpc/grpc-js';
import type { VaultManager } from '../../vaults';
import type * as utilsPB from '../../proto/js/polykey/v1/utils/utils_pb';
import type { ConnectionInfoGetter } from 'agent/types';
import type { ConnectionInfoGet } from 'agent/types';
import * as agentErrors from 'agent/errors';
import * as vaultsPB from '../../proto/js/polykey/v1/vaults/vaults_pb';
import { utils as vaultsUtils } from '../../vaults';
import { utils as grpcUtils } from '../../grpc';
import { never } from '../../utils/utils';

function vaultsScan({
vaultManager,
connectionInfoGetter,
connectionInfoGet,
}: {
vaultManager: VaultManager;
connectionInfoGetter: ConnectionInfoGetter;
connectionInfoGet: ConnectionInfoGet;
}) {
return async (
call: grpc.ServerWritableStream<utilsPB.EmptyMessage, vaultsPB.List>,
): Promise<void> => {
const genWritable = grpcUtils.generatorWritable(call);
const listMessage = new vaultsPB.List();
// Getting the NodeId from the ReverseProxy connection info
const connectionInfo = connectionInfoGetter(call.getPeer());
const connectionInfo = connectionInfoGet(call);
// If this is getting run the connection exists
// It SHOULD exist here
if (connectionInfo == null) never();
if (connectionInfo == null) {
throw new agentErrors.ErrorConnectionInfoMissing();
}
const nodeId = connectionInfo.nodeId;
try {
const listResponse = vaultManager.handleScanVaults(nodeId);
Expand Down

0 comments on commit af5cd57

Please sign in to comment.