Skip to content

Commit

Permalink
node::provision: Compute MachineId only once
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFangX committed Nov 12, 2023
1 parent 4cc308d commit e8983eb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions node/src/provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use common::{
cli::node::ProvisionArgs,
client::tls,
enclave,
enclave::Measurement,
enclave::{MachineId, Measurement},
net,
rng::{Crng, SysRng},
shutdown::ShutdownChannel,
Expand All @@ -55,6 +55,7 @@ const WARP_SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(2);
struct RequestContext {
args: Arc<ProvisionArgs>,
client: reqwest::Client,
machine_id: MachineId,
measurement: Measurement,
backend_api: Arc<dyn BackendApiClient + Send + Sync>,
// TODO(phlip9): make generic, use test rng in test
Expand All @@ -79,10 +80,12 @@ pub async fn provision_node<R: Crng>(
// TODO(phlip9): Add Google certs here once the webpki feature is removed
// from the `gdrive` crate
let client = reqwest::Client::new();
let machine_id = enclave::machine_id();
let measurement = enclave::measurement();
let ctx = RequestContext {
args: args.clone(),
client,
machine_id,
measurement,
backend_api,
// TODO(phlip9): use passed in rng
Expand Down Expand Up @@ -230,7 +233,7 @@ mod handlers {
req.deploy_env,
req.network,
ctx.measurement,
enclave::machine_id(),
ctx.machine_id,
);

let sealed_seed = sealed_seed_res.map_err(|err| NodeApiError {
Expand Down

0 comments on commit e8983eb

Please sign in to comment.