mirror of
https://github.com/uqbar-dao/nectar.git
synced 2025-01-02 05:28:22 +03:00
Format Rust code using rustfmt
This commit is contained in:
parent
12f9ccdcb2
commit
fa449a3d84
@ -3,7 +3,9 @@ use crate::net::{
|
|||||||
types::{HandshakePayload, IdentityExt, Peers},
|
types::{HandshakePayload, IdentityExt, Peers},
|
||||||
utils::{print_debug, print_loud, IDLE_TIMEOUT, MESSAGE_MAX_SIZE},
|
utils::{print_debug, print_loud, IDLE_TIMEOUT, MESSAGE_MAX_SIZE},
|
||||||
};
|
};
|
||||||
use lib::types::core::{check_process_id_kimap_safe, KernelMessage, MessageSender, NodeId, PrintSender};
|
use lib::types::core::{
|
||||||
|
check_process_id_kimap_safe, KernelMessage, MessageSender, NodeId, PrintSender,
|
||||||
|
};
|
||||||
use {
|
use {
|
||||||
tokio::io::{AsyncReadExt, AsyncWriteExt},
|
tokio::io::{AsyncReadExt, AsyncWriteExt},
|
||||||
tokio::net::{tcp::OwnedReadHalf, tcp::OwnedWriteHalf, TcpStream},
|
tokio::net::{tcp::OwnedReadHalf, tcp::OwnedWriteHalf, TcpStream},
|
||||||
@ -67,7 +69,10 @@ pub async fn maintain_connection(
|
|||||||
if check_process_id_kimap_safe(&km.source.process).is_err() {
|
if check_process_id_kimap_safe(&km.source.process).is_err() {
|
||||||
print_loud(
|
print_loud(
|
||||||
&read_print_tx,
|
&read_print_tx,
|
||||||
&format!("net: got message from non-Kimap-safe process: {}", km.source),
|
&format!(
|
||||||
|
"net: got message from non-Kimap-safe process: {}",
|
||||||
|
km.source
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
break;
|
break;
|
||||||
|
@ -88,7 +88,10 @@ pub async fn maintain_connection(
|
|||||||
if check_process_id_kimap_safe(&km.source.process).is_err() {
|
if check_process_id_kimap_safe(&km.source.process).is_err() {
|
||||||
print_loud(
|
print_loud(
|
||||||
&read_print_tx,
|
&read_print_tx,
|
||||||
&format!("net: got message from non-Kimap-safe process: {}", km.source),
|
&format!(
|
||||||
|
"net: got message from non-Kimap-safe process: {}",
|
||||||
|
km.source
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
break;
|
break;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use lib::types::core::{
|
use lib::types::core::{
|
||||||
Address, Capability, check_process_id_kimap_safe, Erc721Metadata, KernelMessage, LazyLoadBlob, Message, MessageReceiver,
|
check_process_id_kimap_safe, Address, Capability, Erc721Metadata, KernelMessage, LazyLoadBlob,
|
||||||
MessageSender, NetworkErrorSender, OnExit, PackageManifestEntry, PersistedProcess, PrintSender,
|
Message, MessageReceiver, MessageSender, NetworkErrorSender, OnExit, PackageManifestEntry,
|
||||||
Printout, ProcessId, ProcessMap, Request, Response, ReverseCapIndex, StateAction, StateError,
|
PersistedProcess, PrintSender, Printout, ProcessId, ProcessMap, Request, Response,
|
||||||
StateResponse, KERNEL_PROCESS_ID, STATE_PROCESS_ID, VFS_PROCESS_ID,
|
ReverseCapIndex, StateAction, StateError, StateResponse, KERNEL_PROCESS_ID, STATE_PROCESS_ID,
|
||||||
|
VFS_PROCESS_ID,
|
||||||
};
|
};
|
||||||
use ring::signature;
|
use ring::signature;
|
||||||
use rocksdb::{checkpoint::Checkpoint, Options, DB};
|
use rocksdb::{checkpoint::Checkpoint, Options, DB};
|
||||||
|
@ -58,13 +58,19 @@ pub fn is_kimap_safe_no_dots(input: &str) -> bool {
|
|||||||
|
|
||||||
pub fn check_process_id_kimap_safe(p: &ProcessId) -> Result<(), AddressParseError> {
|
pub fn check_process_id_kimap_safe(p: &ProcessId) -> Result<(), AddressParseError> {
|
||||||
if !is_kimap_safe_no_dots(&p.process_name) {
|
if !is_kimap_safe_no_dots(&p.process_name) {
|
||||||
return Err(AddressParseError::ProcessNameNotKimapSafe(p.process_name.clone()));
|
return Err(AddressParseError::ProcessNameNotKimapSafe(
|
||||||
|
p.process_name.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if !is_kimap_safe_no_dots(&p.package_name) {
|
if !is_kimap_safe_no_dots(&p.package_name) {
|
||||||
return Err(AddressParseError::PackageNameNotKimapSafe(p.package_name.clone()));
|
return Err(AddressParseError::PackageNameNotKimapSafe(
|
||||||
|
p.package_name.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if !is_kimap_safe(&p.publisher_node) {
|
if !is_kimap_safe(&p.publisher_node) {
|
||||||
return Err(AddressParseError::PublisherNodeNotKimapSafe(p.publisher_node.clone()));
|
return Err(AddressParseError::PublisherNodeNotKimapSafe(
|
||||||
|
p.publisher_node.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -105,11 +111,7 @@ impl<'a> Deserialize<'a> for ProcessId {
|
|||||||
/// are defined here.
|
/// are defined here.
|
||||||
impl ProcessId {
|
impl ProcessId {
|
||||||
/// generates a random u64 number if process_name is not declared
|
/// generates a random u64 number if process_name is not declared
|
||||||
pub fn new(
|
pub fn new(process_name: Option<&str>, package_name: &str, publisher_node: &str) -> Self {
|
||||||
process_name: Option<&str>,
|
|
||||||
package_name: &str,
|
|
||||||
publisher_node: &str,
|
|
||||||
) -> Self {
|
|
||||||
let process_name = process_name
|
let process_name = process_name
|
||||||
.unwrap_or(&rand::random::<u64>().to_string())
|
.unwrap_or(&rand::random::<u64>().to_string())
|
||||||
.to_string();
|
.to_string();
|
||||||
@ -191,7 +193,11 @@ impl std::str::FromStr for ProcessId {
|
|||||||
if publisher_node.is_empty() {
|
if publisher_node.is_empty() {
|
||||||
return Err(AddressParseError::MissingField);
|
return Err(AddressParseError::MissingField);
|
||||||
}
|
}
|
||||||
Ok(ProcessId::new(Some(process_name), package_name, publisher_node))
|
Ok(ProcessId::new(
|
||||||
|
Some(process_name),
|
||||||
|
package_name,
|
||||||
|
publisher_node,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +400,10 @@ impl std::str::FromStr for Address {
|
|||||||
if publisher_node.is_empty() {
|
if publisher_node.is_empty() {
|
||||||
return Err(AddressParseError::MissingField);
|
return Err(AddressParseError::MissingField);
|
||||||
}
|
}
|
||||||
Ok(Address::new(node, (process_name, package_name, publisher_node)))
|
Ok(Address::new(
|
||||||
|
node,
|
||||||
|
(process_name, package_name, publisher_node),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user