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