allow to get contract by uuid

This commit is contained in:
ghe0 2024-12-30 04:49:08 +02:00
parent ac2012f04d
commit 3b62e4d2bd
Signed by: ghe0
GPG Key ID: 451028EE56A0FBB4
2 changed files with 8 additions and 1 deletions

@ -77,6 +77,7 @@ message VMContract {
message ListVMContractsReq {
string admin_pubkey = 1;
string node_pubkey = 2;
string uuid = 3;
}
message NewVmRespIP {

@ -340,7 +340,13 @@ impl BrainCliService for BrainCliMock {
) -> Result<Response<Self::ListVMContractsStream>, Status> {
let req = req.into_inner();
info!("CLI {} requested ListVMContractsStream", req.admin_pubkey);
let contracts = self.data.find_contracts_by_admin_pubkey(&req.admin_pubkey);
let contracts = match req.uuid.is_empty() {
false => match self.data.find_contract_by_uuid(&req.uuid) {
Some(contract) => vec![contract],
None => Vec::new(),
},
true => self.data.find_contracts_by_admin_pubkey(&req.admin_pubkey),
};
let (tx, rx) = mpsc::channel(6);
tokio::spawn(async move {
for contract in contracts {