Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions kinode/src/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ enum ProcessSender {
}

/// persist kernel's process_map state for next bootup
/// and (TODO) wait for filesystem to respond in the affirmative
async fn persist_state(
our_name: &str,
send_to_loop: &t::MessageSender,
Expand Down Expand Up @@ -76,7 +75,7 @@ async fn persist_state(
Ok(())
}

/// handle messages sent directly to kernel. source is always our own node.
/// handle commands inside messages sent directly to kernel. source is always our own node.
async fn handle_kernel_request(
our_name: String,
keypair: Arc<signature::Ed25519KeyPair>,
Expand Down Expand Up @@ -528,7 +527,7 @@ async fn handle_kernel_request(
}
}

// double check immediate run
/// spawn a process loop and insert the process in the relevant kernel state maps
async fn start_process(
our_name: String,
keypair: Arc<signature::Ed25519KeyPair>,
Expand Down Expand Up @@ -1097,23 +1096,15 @@ pub async fn kernel(
match process_map.get(&on) {
None => vec![],
Some(p) => {
caps.iter().filter_map(|cap| {
caps.into_iter().filter_map(|cap| {
// if issuer is message source, then sign the cap
if cap.issuer.process == on {
Some((
cap.clone(),
keypair
.sign(&rmp_serde::to_vec(&cap).unwrap())
.as_ref()
.to_vec()
))
let sig = keypair.sign(&rmp_serde::to_vec(&cap).unwrap());
Some((cap, sig.as_ref().to_vec()))
// otherwise, only attach previously saved caps
// NOTE we don't need to verify the sigs!
} else {
match p.capabilities.get(cap) {
None => None,
Some(sig) => Some((cap.clone(), sig.clone()))
}
p.capabilities.get(&cap).map(|sig| (cap, sig.clone()))
}
}).collect()
},
Expand Down
Loading