Skip to content

Commit

Permalink
feat: transfer state across worker boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Jan 22, 2024
1 parent 03a241c commit 6001521
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/beacon-node/src/chain/historicalState/worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import worker from "node:worker_threads";
import {expose} from "@chainsafe/threads/worker";
import {Transfer, expose} from "@chainsafe/threads/worker";
import {createBeaconConfig, chainConfigFromJson} from "@lodestar/config";
import {getNodeLogger} from "@lodestar/logger/node";
import {
Expand Down Expand Up @@ -166,7 +166,10 @@ const api: HistoricalStateWorkerApi = {
return metricsRegister?.metrics() ?? "";
},
async getHistoricalState(slot) {
return queue.push(() => getHistoricalState(slot, config, db, pubkey2index, stateTransitionMetrics));
const state = await queue.push<Uint8Array>(() =>
getHistoricalState(slot, config, db, pubkey2index, stateTransitionMetrics)
);
return Transfer(state, [state.buffer]) as unknown as Uint8Array;
},
};

Expand Down

0 comments on commit 6001521

Please sign in to comment.