forked from ghe0/brain-mock
refactor: rename admin_pubkey to owner_wallet in AppContract and related functions
This commit is contained in:
parent
f1a527e22d
commit
3b3221099f
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -418,7 +418,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "detee-shared"
|
||||
version = "0.1.0"
|
||||
source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared?branch=stable_01#65bfa113a44251dd13e5d895014f4a773e367d2e"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"prost",
|
||||
|
16
src/data.rs
16
src/data.rs
@ -142,7 +142,7 @@ impl Into<grpc::VmContract> for VmContract {
|
||||
pub struct AppContract {
|
||||
pub uuid: String,
|
||||
pub package_url: String,
|
||||
pub admin_pubkey: String,
|
||||
pub owner_wallet: String,
|
||||
pub node_pubkey: String,
|
||||
pub mapped_ports: Vec<(u16, u16)>,
|
||||
pub host_ipv4: String,
|
||||
@ -162,7 +162,7 @@ impl From<AppContract> for AppContractPB {
|
||||
fn from(value: AppContract) -> Self {
|
||||
Self {
|
||||
uuid: value.uuid,
|
||||
admin_pubkey: value.admin_pubkey,
|
||||
owner_wallet: value.owner_wallet,
|
||||
node_pubkey: value.node_pubkey,
|
||||
package_url: value.package_url,
|
||||
exposed_ports: value
|
||||
@ -797,17 +797,17 @@ impl BrainData {
|
||||
contracts.iter().find(|c| c.uuid == uuid).cloned()
|
||||
}
|
||||
|
||||
pub fn find_app_contracts_by_admin_pubkey(&self, admin_pubkey: &str) -> Vec<AppContract> {
|
||||
debug!("Searching contracts for admin pubkey {admin_pubkey}");
|
||||
pub fn find_app_contracts_by_admin_pubkey(&self, owner_wallet: &str) -> Vec<AppContract> {
|
||||
debug!("Searching contracts for admin pubkey {owner_wallet}");
|
||||
let contracts: Vec<AppContract> = self
|
||||
.app_contracts
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|c| c.admin_pubkey == admin_pubkey)
|
||||
.filter(|c| c.owner_wallet == owner_wallet)
|
||||
.cloned()
|
||||
.collect();
|
||||
debug!("Found {} contracts or {admin_pubkey}.", contracts.len());
|
||||
debug!("Found {} contracts or {owner_wallet}.", contracts.len());
|
||||
contracts
|
||||
}
|
||||
|
||||
@ -906,7 +906,7 @@ impl BrainData {
|
||||
if let Err(err) = new_container_req.1.send(new_container_resp.clone()) {
|
||||
log::error!(
|
||||
"CLI RX for {} dropped before receiving confirmation {:?}.\n{:?}",
|
||||
&new_container_req.0.admin_pubkey,
|
||||
&new_container_req.0.owner_wallet,
|
||||
new_container_resp,
|
||||
err
|
||||
);
|
||||
@ -916,7 +916,7 @@ impl BrainData {
|
||||
uuid: new_container_req.0.uuid,
|
||||
node_pubkey: new_container_req.0.node_pubkey.clone(),
|
||||
package_url: new_container_req.0.package_url,
|
||||
admin_pubkey: new_container_req.0.admin_pubkey,
|
||||
owner_wallet: new_container_req.0.owner_wallet,
|
||||
..Default::default()
|
||||
};
|
||||
log::info!("Created new app contract: {app_contracts:?}");
|
||||
|
@ -368,13 +368,13 @@ impl BrainAppCli for BrainAppCliMock {
|
||||
) -> Result<tonic::Response<NewAppRes>, Status> {
|
||||
let req = req.into_inner();
|
||||
log::info!("Creating new container: {req:?}");
|
||||
let admin_pubkey = req.admin_pubkey.clone();
|
||||
let owner_wallet = req.owner_wallet.clone();
|
||||
let (oneshot_tx, oneshot_rx) = tokio::sync::oneshot::channel();
|
||||
self.data.send_new_container_req(req, oneshot_tx).await;
|
||||
|
||||
match oneshot_rx.await {
|
||||
Ok(response) => {
|
||||
info!("responding container confirmation to {admin_pubkey}: {response:?}");
|
||||
info!("responding container confirmation to {owner_wallet}: {response:?}");
|
||||
Ok(Response::new(response))
|
||||
}
|
||||
Err(e) => {
|
||||
@ -409,7 +409,7 @@ impl BrainAppCli for BrainAppCliMock {
|
||||
|
||||
let app_contracts = self
|
||||
.data
|
||||
.find_app_contracts_by_admin_pubkey(&req_data.admin_pubkey);
|
||||
.find_app_contracts_by_admin_pubkey(&req_data.owner_wallet);
|
||||
|
||||
let (tx, rx) = mpsc::channel(6);
|
||||
tokio::spawn(async move {
|
||||
|
Loading…
Reference in New Issue
Block a user