forked from ghe0/brain-mock
allow to get contract by uuid
This commit is contained in:
parent
ac2012f04d
commit
3b62e4d2bd
@ -77,6 +77,7 @@ message VMContract {
|
|||||||
message ListVMContractsReq {
|
message ListVMContractsReq {
|
||||||
string admin_pubkey = 1;
|
string admin_pubkey = 1;
|
||||||
string node_pubkey = 2;
|
string node_pubkey = 2;
|
||||||
|
string uuid = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message NewVmRespIP {
|
message NewVmRespIP {
|
||||||
|
@ -340,7 +340,13 @@ impl BrainCliService for BrainCliMock {
|
|||||||
) -> Result<Response<Self::ListVMContractsStream>, Status> {
|
) -> Result<Response<Self::ListVMContractsStream>, Status> {
|
||||||
let req = req.into_inner();
|
let req = req.into_inner();
|
||||||
info!("CLI {} requested ListVMContractsStream", req.admin_pubkey);
|
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);
|
let (tx, rx) = mpsc::channel(6);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
for contract in contracts {
|
for contract in contracts {
|
||||||
|
Loading…
Reference in New Issue
Block a user