mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-30 12:03:42 +03:00
clean up calls that use Address::try_into() under the hood
This commit is contained in:
parent
530b20c5f7
commit
3f6b94076c
@ -1126,7 +1126,7 @@ async fn check_for_root_cap(
|
||||
caps_oracle
|
||||
.send(CapMessage::Has {
|
||||
on: process.clone(),
|
||||
cap: Capability::new((our, Ð_PROCESS_ID.clone()), "{\"root\":true}").unwrap(),
|
||||
cap: Capability::new((our, ETH_PROCESS_ID.clone()), "{\"root\":true}").unwrap(),
|
||||
responder: send_cap_bool,
|
||||
})
|
||||
.await
|
||||
|
@ -340,7 +340,7 @@ async fn send_all_fds_limits(our_node: &str, send_to_loop: &MessageSender, state
|
||||
for (process_id, limit) in &state.fds_limits {
|
||||
KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((our_node, &FD_MANAGER_PROCESS_ID.clone()))
|
||||
.source((our_node, FD_MANAGER_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target((our_node, process_id))
|
||||
.unwrap()
|
||||
@ -386,7 +386,6 @@ async fn send_to_fd_manager(our: &Address, message: Message, send_to_loop: &Mess
|
||||
.source(our.clone())
|
||||
.unwrap()
|
||||
.target((our.node.clone(), FD_MANAGER_PROCESS_ID.clone()))
|
||||
//.target((our.node.clone(), &FD_MANAGER_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.message(message)
|
||||
.build()
|
||||
|
@ -931,7 +931,7 @@ async fn maintain_websocket(
|
||||
|
||||
KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&*our, &HTTP_SERVER_PROCESS_ID.clone()))
|
||||
.source((&*our, HTTP_SERVER_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target((&*our, &app))
|
||||
.unwrap()
|
||||
@ -1017,7 +1017,7 @@ async fn websocket_close(
|
||||
ws_senders.remove(&channel_id);
|
||||
KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source(("our", &HTTP_SERVER_PROCESS_ID.clone()))
|
||||
.source(("our", HTTP_SERVER_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(("our", &process))
|
||||
.unwrap()
|
||||
@ -1384,7 +1384,7 @@ pub async fn send_action_response(
|
||||
) {
|
||||
KernelMessage::builder()
|
||||
.id(id)
|
||||
.source(("our", &HTTP_SERVER_PROCESS_ID.clone()))
|
||||
.source(("our", HTTP_SERVER_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(target)
|
||||
.unwrap()
|
||||
|
@ -44,9 +44,9 @@ enum ProcessSender {
|
||||
async fn persist_state(send_to_loop: &t::MessageSender, process_map: &t::ProcessMap) {
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source(("our", &KERNEL_PROCESS_ID.clone()))
|
||||
.source(("our", KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(("our", &STATE_PROCESS_ID.clone()))
|
||||
.target(("our", STATE_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
@ -112,7 +112,7 @@ async fn handle_kernel_request(
|
||||
sender
|
||||
.send(Ok(t::KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source((our_name, &KERNEL_PROCESS_ID.clone()))
|
||||
.source((our_name, KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target((our_name, process_id))
|
||||
.unwrap()
|
||||
@ -148,7 +148,7 @@ async fn handle_kernel_request(
|
||||
// fire an error back
|
||||
t::KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source((our_name, &KERNEL_PROCESS_ID.clone()))
|
||||
.source((our_name, KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km.rsvp.unwrap_or(km.source))
|
||||
.unwrap()
|
||||
@ -268,7 +268,7 @@ async fn handle_kernel_request(
|
||||
};
|
||||
t::KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source(("our", &KERNEL_PROCESS_ID.clone()))
|
||||
.source(("our", KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km.rsvp.unwrap_or(km.source))
|
||||
.unwrap()
|
||||
@ -324,7 +324,7 @@ async fn handle_kernel_request(
|
||||
if let Ok(()) = process_sender
|
||||
.send(Ok(t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((our_name, &KERNEL_PROCESS_ID.clone()))
|
||||
.source((our_name, KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target((our_name, &process_id))
|
||||
.unwrap()
|
||||
@ -351,7 +351,7 @@ async fn handle_kernel_request(
|
||||
};
|
||||
t::KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source(("our", &KERNEL_PROCESS_ID.clone()))
|
||||
.source(("our", KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km.rsvp.unwrap_or(km.source))
|
||||
.unwrap()
|
||||
@ -410,7 +410,7 @@ async fn handle_kernel_request(
|
||||
.await;
|
||||
t::KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source(("our", &KERNEL_PROCESS_ID.clone()))
|
||||
.source(("our", KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km.rsvp.unwrap_or(km.source))
|
||||
.unwrap()
|
||||
@ -450,7 +450,7 @@ async fn handle_kernel_request(
|
||||
};
|
||||
t::KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source(("our", &KERNEL_PROCESS_ID.clone()))
|
||||
.source(("our", KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km.rsvp.unwrap_or(km.source))
|
||||
.unwrap()
|
||||
@ -689,8 +689,8 @@ pub async fn kernel(
|
||||
// to turn it on
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.name, &KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.name, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.name, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.name, KERNEL_PROCESS_ID.clone()))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: true,
|
||||
expects_response: None,
|
||||
@ -706,7 +706,7 @@ pub async fn kernel(
|
||||
// sending hard coded pki entries into networking for bootstrapped rpc
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.name, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.name, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((our.name.as_str(), "net", "distro", "sys"))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
@ -791,7 +791,7 @@ pub async fn kernel(
|
||||
continue;
|
||||
};
|
||||
if !proc.capabilities.contains_key(
|
||||
&t::Capability::new((&our.name, &KERNEL_PROCESS_ID.clone()), "\"network\"")?
|
||||
&t::Capability::new((&our.name, KERNEL_PROCESS_ID.clone()), "\"network\"")?
|
||||
) {
|
||||
// capabilities are not correct! skip this message.
|
||||
t::Printout::new(
|
||||
@ -832,7 +832,7 @@ pub async fn kernel(
|
||||
continue;
|
||||
};
|
||||
if !persisted.capabilities.contains_key(
|
||||
&t::Capability::new((&our.name, &KERNEL_PROCESS_ID.clone()), "\"network\"")?
|
||||
&t::Capability::new((&our.name, KERNEL_PROCESS_ID.clone()), "\"network\"")?
|
||||
) {
|
||||
// capabilities are not correct! skip this message.
|
||||
t::Printout::new(
|
||||
@ -868,7 +868,7 @@ pub async fn kernel(
|
||||
};
|
||||
if !persisted_target.public
|
||||
&& !persisted_source.capabilities.contains_key(
|
||||
&t::Capability::messaging((&our.name, &kernel_message.target.process.clone()))?
|
||||
&t::Capability::messaging((&our.name, &kernel_message.target.process))?
|
||||
) {
|
||||
// capabilities are not correct! skip this message.
|
||||
t::Printout::new(
|
||||
|
@ -370,8 +370,8 @@ pub async fn make_process_loop(
|
||||
t::OnExit::None => {
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
expects_response: None,
|
||||
@ -409,8 +409,8 @@ pub async fn make_process_loop(
|
||||
// kill, **without** revoking capabilities from others!
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
expects_response: None,
|
||||
@ -428,8 +428,8 @@ pub async fn make_process_loop(
|
||||
// then re-initialize with same capabilities
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
expects_response: None,
|
||||
@ -456,8 +456,8 @@ pub async fn make_process_loop(
|
||||
// then run
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
expects_response: None,
|
||||
@ -491,8 +491,8 @@ pub async fn make_process_loop(
|
||||
}
|
||||
t::KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, &KERNEL_PROCESS_ID.clone()))?
|
||||
.source((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.target((&our.node, KERNEL_PROCESS_ID.clone()))?
|
||||
.message(t::Message::Request(t::Request {
|
||||
inherit: false,
|
||||
expects_response: None,
|
||||
|
@ -482,9 +482,9 @@ async fn main() {
|
||||
Ok(()) => {
|
||||
KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((our.name.as_str(), &KERNEL_PROCESS_ID.clone()))
|
||||
.source((our.name.as_str(), KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target((our.name.as_str(), &KERNEL_PROCESS_ID.clone()))
|
||||
.target((our.name.as_str(), KERNEL_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.message(Message::Request(Request {
|
||||
inherit: false,
|
||||
|
@ -153,7 +153,7 @@ pub async fn state_sender(
|
||||
{
|
||||
KernelMessage::builder()
|
||||
.id(km_id)
|
||||
.source((our_node.as_str(), &STATE_PROCESS_ID.clone()))
|
||||
.source((our_node.as_str(), STATE_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km_rsvp)
|
||||
.unwrap()
|
||||
@ -290,7 +290,7 @@ async fn handle_request(
|
||||
if let Some(target) = rsvp.or_else(|| expects_response.map(|_| source)) {
|
||||
KernelMessage::builder()
|
||||
.id(id)
|
||||
.source((our_node, &STATE_PROCESS_ID.clone()))
|
||||
.source((our_node, STATE_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(target)
|
||||
.unwrap()
|
||||
|
@ -837,8 +837,8 @@ async fn handle_key_event(
|
||||
command_history.add(command.to_string());
|
||||
KernelMessage::builder()
|
||||
.id(rand::random())
|
||||
.source((our.name.as_str(), &TERMINAL_PROCESS_ID.clone()))?
|
||||
.target((our.name.as_str(), &TERMINAL_PROCESS_ID.clone()))?
|
||||
.source((our.name.as_str(), TERMINAL_PROCESS_ID.clone()))?
|
||||
.target((our.name.as_str(), TERMINAL_PROCESS_ID.clone()))?
|
||||
.message(Message::Request(Request {
|
||||
inherit: false,
|
||||
expects_response: None,
|
||||
|
@ -82,7 +82,7 @@ pub async fn timer_service(
|
||||
if timer_millis == 0 {
|
||||
KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source((our.as_str(), &TIMER_PROCESS_ID.clone()))?
|
||||
.source((our.as_str(), TIMER_PROCESS_ID.clone()))?
|
||||
.target(km.rsvp.unwrap_or(km.source))?
|
||||
.message(Message::Response((
|
||||
Response {
|
||||
@ -116,7 +116,7 @@ pub async fn timer_service(
|
||||
for (id, addr) in timers {
|
||||
KernelMessage::builder()
|
||||
.id(id)
|
||||
.source((our.as_str(), &TIMER_PROCESS_ID.clone()))?
|
||||
.source((our.as_str(), TIMER_PROCESS_ID.clone()))?
|
||||
.target(addr)?
|
||||
.message(Message::Response((
|
||||
Response {
|
||||
|
@ -50,7 +50,7 @@ pub async fn vfs(
|
||||
let vfs_path = Arc::new(fs::canonicalize(&vfs_path).await?);
|
||||
|
||||
let mut files = Files::new(
|
||||
Address::try_new(our_node.as_str(), &VFS_PROCESS_ID.clone())?,
|
||||
Address::try_new(our_node.as_str(), VFS_PROCESS_ID.clone())?,
|
||||
send_to_loop,
|
||||
);
|
||||
|
||||
@ -112,7 +112,7 @@ pub async fn vfs(
|
||||
{
|
||||
KernelMessage::builder()
|
||||
.id(km_id)
|
||||
.source((our_node.as_str(), &VFS_PROCESS_ID.clone()))
|
||||
.source((our_node.as_str(), VFS_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km_rsvp)
|
||||
.unwrap()
|
||||
@ -319,7 +319,7 @@ async fn handle_request(
|
||||
|
||||
KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source((our_node, &VFS_PROCESS_ID.clone()))
|
||||
.source((our_node, VFS_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(km.source)
|
||||
.unwrap()
|
||||
@ -647,7 +647,7 @@ async fn handle_request(
|
||||
if let Some(target) = km.rsvp.or_else(|| expects_response.map(|_| km.source)) {
|
||||
KernelMessage::builder()
|
||||
.id(km.id)
|
||||
.source((our_node, &VFS_PROCESS_ID.clone()))
|
||||
.source((our_node, VFS_PROCESS_ID.clone()))
|
||||
.unwrap()
|
||||
.target(target)
|
||||
.unwrap()
|
||||
@ -925,7 +925,7 @@ async fn read_capability(
|
||||
) -> bool {
|
||||
let (send_cap_bool, recv_cap_bool) = tokio::sync::oneshot::channel();
|
||||
let cap = Capability::new(
|
||||
(our_node, &VFS_PROCESS_ID.clone()),
|
||||
(our_node, VFS_PROCESS_ID.clone()),
|
||||
if root {
|
||||
"{\"root\":true}".to_string()
|
||||
} else {
|
||||
@ -954,7 +954,7 @@ async fn add_capability(
|
||||
send_to_caps_oracle: &CapMessageSender,
|
||||
) -> Result<(), VfsError> {
|
||||
let cap = Capability::new(
|
||||
(our_node, &VFS_PROCESS_ID.clone()),
|
||||
(our_node, VFS_PROCESS_ID.clone()),
|
||||
format!("{{\"kind\": \"{kind}\", \"drive\": \"{drive}\"}}"),
|
||||
)
|
||||
.unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user