Skip to content

Commit

Permalink
[worker] setShieldingKey internally when it is fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Apr 11, 2024
1 parent 0eb6c7b commit 90b7b25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/worker-api/src/integriteeWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ export class IntegriteeWorker extends Worker {
return this.sendTrustedCall(call, shard, options);
}

async sendTrustedCall(call: IntegriteeTrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise<Hash> {
async sendTrustedCall(call: IntegriteeTrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise<Hash> {
if (this.shieldingKey() == undefined) {
const key = await this.getShieldingKey(options);
console.log(`Setting the shielding pubKey of the worker.`)
this.setShieldingKey(key);
await this.getShieldingKey(options);
}

return sendTrustedCall<Hash>(this, call, shard, true, 'TrustedOperationResult', options);
Expand Down
4 changes: 3 additions & 1 deletion packages/worker-api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ export class Worker extends WebSocketAsPromised implements IWorker {
}

public async getShieldingKey(options: CallOptions = {} as CallOptions): Promise<NodeRSA> {
return await callGetter<NodeRSA>(this, [Request.Worker, 'author_getShieldingKey', 'NodeRSA'], {}, options)
const key = await callGetter<NodeRSA>(this, [Request.Worker, 'author_getShieldingKey', 'NodeRSA'], {}, options)
this.setShieldingKey(key);
return key;
}

public async getShardVault(options: CallOptions = {} as CallOptions): Promise<Vault> {
Expand Down

0 comments on commit 90b7b25

Please sign in to comment.