cargo fmt
This commit is contained in:
parent
46ba0961bf
commit
547246629b
@ -6,9 +6,8 @@ use super::Error;
|
|||||||
use crate::constants::{
|
use crate::constants::{
|
||||||
ACCOUNT, ACTIVE_APP, APP_DAEMON_TIMEOUT, APP_NODE, DEFAULT_ENDPOINT, DELETED_APP, NEW_APP_REQ,
|
ACCOUNT, ACTIVE_APP, APP_DAEMON_TIMEOUT, APP_NODE, DEFAULT_ENDPOINT, DELETED_APP, NEW_APP_REQ,
|
||||||
};
|
};
|
||||||
use crate::db;
|
|
||||||
use crate::db::general::Report;
|
use crate::db::general::Report;
|
||||||
use crate::old_brain;
|
use crate::{db, old_brain};
|
||||||
use detee_shared::app_proto::{self, NewAppRes};
|
use detee_shared::app_proto::{self, NewAppRes};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use surrealdb::engine::remote::ws::Client;
|
use surrealdb::engine::remote::ws::Client;
|
||||||
|
@ -12,8 +12,7 @@ use log::info;
|
|||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use surrealdb::engine::remote::ws::Client;
|
use surrealdb::engine::remote::ws::Client;
|
||||||
use surrealdb::RecordId;
|
use surrealdb::{RecordId, Surreal};
|
||||||
use surrealdb::Surreal;
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
use tokio_stream::{Stream, StreamExt};
|
use tokio_stream::{Stream, StreamExt};
|
||||||
@ -31,8 +30,8 @@ impl AppDaemonServer {
|
|||||||
|
|
||||||
#[tonic::async_trait]
|
#[tonic::async_trait]
|
||||||
impl BrainAppDaemon for AppDaemonServer {
|
impl BrainAppDaemon for AppDaemonServer {
|
||||||
type RegisterAppNodeStream = Pin<Box<dyn Stream<Item = Result<DelAppReq, Status>> + Send>>;
|
|
||||||
type BrainMessagesStream = Pin<Box<dyn Stream<Item = Result<BrainMessageApp, Status>> + Send>>;
|
type BrainMessagesStream = Pin<Box<dyn Stream<Item = Result<BrainMessageApp, Status>> + Send>>;
|
||||||
|
type RegisterAppNodeStream = Pin<Box<dyn Stream<Item = Result<DelAppReq, Status>> + Send>>;
|
||||||
|
|
||||||
async fn register_app_node(
|
async fn register_app_node(
|
||||||
&self,
|
&self,
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
use crate::constants::{ACCOUNT, APP_NODE, ID_ALPHABET, NEW_APP_REQ, NEW_VM_REQ, VM_NODE};
|
use crate::constants::{ACCOUNT, APP_NODE, ID_ALPHABET, NEW_APP_REQ, NEW_VM_REQ, VM_NODE};
|
||||||
use crate::db::prelude as db;
|
use crate::db::prelude as db;
|
||||||
use detee_shared::app_proto::AppNodeListResp;
|
use detee_shared::app_proto::*;
|
||||||
use detee_shared::common_proto::MappedPort;
|
use detee_shared::common_proto::MappedPort;
|
||||||
use detee_shared::general_proto::{Account, AccountBalance, ListOperatorsResp};
|
use detee_shared::general_proto::{Account, AccountBalance, ListOperatorsResp};
|
||||||
use detee_shared::{app_proto::*, vm_proto::*};
|
use detee_shared::vm_proto::*;
|
||||||
use nanoid::nanoid;
|
use nanoid::nanoid;
|
||||||
|
|
||||||
use surrealdb::RecordId;
|
use surrealdb::RecordId;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use detee_shared::app_proto::{
|
use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient;
|
||||||
brain_app_cli_client::BrainAppCliClient, AppResource, NewAppReq, NewAppRes,
|
use detee_shared::app_proto::{AppResource, NewAppReq, NewAppRes};
|
||||||
};
|
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::Channel;
|
||||||
|
|
||||||
use crate::common::test_utils::Key;
|
use crate::common::test_utils::Key;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use detee_shared::app_proto as sgx_proto;
|
|
||||||
use detee_shared::general_proto::brain_general_cli_client::BrainGeneralCliClient;
|
use detee_shared::general_proto::brain_general_cli_client::BrainGeneralCliClient;
|
||||||
use detee_shared::general_proto::AirdropReq;
|
use detee_shared::general_proto::AirdropReq;
|
||||||
use detee_shared::vm_proto as snp_proto;
|
use detee_shared::{app_proto, vm_proto};
|
||||||
use ed25519_dalek::{Signer, SigningKey};
|
use ed25519_dalek::{Signer, SigningKey};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
@ -75,20 +74,20 @@ impl Key {
|
|||||||
pub fn sign_stream_auth_vm(
|
pub fn sign_stream_auth_vm(
|
||||||
&self,
|
&self,
|
||||||
contracts: Vec<String>,
|
contracts: Vec<String>,
|
||||||
) -> Result<snp_proto::DaemonStreamAuth> {
|
) -> Result<vm_proto::DaemonStreamAuth> {
|
||||||
let pubkey = self.pubkey.clone();
|
let pubkey = self.pubkey.clone();
|
||||||
let timestamp = chrono::Utc::now().to_rfc3339();
|
let timestamp = chrono::Utc::now().to_rfc3339();
|
||||||
let signature =
|
let signature =
|
||||||
self.try_sign_message(&(timestamp.to_string() + &format!("{contracts:?}")))?;
|
self.try_sign_message(&(timestamp.to_string() + &format!("{contracts:?}")))?;
|
||||||
Ok(snp_proto::DaemonStreamAuth { timestamp, pubkey, contracts, signature })
|
Ok(vm_proto::DaemonStreamAuth { timestamp, pubkey, contracts, signature })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sign_stream_auth_app(&self, contracts: Vec<String>) -> Result<sgx_proto::DaemonAuth> {
|
pub fn sign_stream_auth_app(&self, contracts: Vec<String>) -> Result<app_proto::DaemonAuth> {
|
||||||
let pubkey = self.pubkey.clone();
|
let pubkey = self.pubkey.clone();
|
||||||
let timestamp = chrono::Utc::now().to_rfc3339();
|
let timestamp = chrono::Utc::now().to_rfc3339();
|
||||||
let signature =
|
let signature =
|
||||||
self.try_sign_message(&(timestamp.to_string() + &format!("{contracts:?}")))?;
|
self.try_sign_message(&(timestamp.to_string() + &format!("{contracts:?}")))?;
|
||||||
Ok(sgx_proto::DaemonAuth { timestamp, pubkey, contracts, signature })
|
Ok(app_proto::DaemonAuth { timestamp, pubkey, contracts, signature })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
use super::test_utils::Key;
|
use super::test_utils::Key;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use detee_shared::app_proto;
|
|
||||||
use detee_shared::common_proto::Empty;
|
use detee_shared::common_proto::Empty;
|
||||||
use detee_shared::general_proto::brain_general_cli_client::BrainGeneralCliClient;
|
use detee_shared::general_proto::brain_general_cli_client::BrainGeneralCliClient;
|
||||||
use detee_shared::general_proto::{Account, RegOperatorReq, ReportNodeReq};
|
use detee_shared::general_proto::{Account, RegOperatorReq, ReportNodeReq};
|
||||||
use detee_shared::vm_proto;
|
|
||||||
use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient;
|
use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient;
|
||||||
|
use detee_shared::{app_proto, vm_proto};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use surreal_brain::constants::{ACTIVE_VM, NEW_VM_REQ};
|
use surreal_brain::constants::{ACTIVE_VM, NEW_VM_REQ};
|
||||||
use surreal_brain::db::prelude as db;
|
use surreal_brain::db::prelude as db;
|
||||||
|
@ -3,12 +3,11 @@
|
|||||||
use common::prepare_test_env::{prepare_test_db, run_service_for_stream};
|
use common::prepare_test_env::{prepare_test_db, run_service_for_stream};
|
||||||
use common::test_utils::{airdrop, Key};
|
use common::test_utils::{airdrop, Key};
|
||||||
use common::vm_daemon_utils::register_vm_node;
|
use common::vm_daemon_utils::register_vm_node;
|
||||||
use detee_shared::app_proto;
|
|
||||||
use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient;
|
use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient;
|
||||||
use detee_shared::app_proto::brain_app_daemon_client::BrainAppDaemonClient;
|
use detee_shared::app_proto::brain_app_daemon_client::BrainAppDaemonClient;
|
||||||
use detee_shared::vm_proto;
|
|
||||||
use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient;
|
use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient;
|
||||||
use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient;
|
use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient;
|
||||||
|
use detee_shared::{app_proto, vm_proto};
|
||||||
|
|
||||||
use crate::common::app_daemon_utils::register_app_node;
|
use crate::common::app_daemon_utils::register_app_node;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user