when node reconnects, send deleted VMs

previously, active VMs were sent
This commit is contained in:
ghe0 2025-05-20 01:45:31 +03:00
parent 32b587c6c5
commit 6a85acda9e
Signed by: ghe0
GPG Key ID: 451028EE56A0FBB4
2 changed files with 6 additions and 6 deletions

2
Cargo.lock generated

@ -1000,7 +1000,7 @@ dependencies = [
[[package]]
name = "detee-shared"
version = "0.1.0"
source = "git+ssh://git@gitea.detee.cloud/testnet/proto?branch=surreal_brain#7ef70689328191fe4951dcf80dae272afdfc8ff2"
source = "git+ssh://git@gitea.detee.cloud/testnet/proto?branch=surreal_brain#d6ca058d2de78b5257517034bca2b2c7d5929db8"
dependencies = [
"bincode 2.0.1",
"prost",

@ -30,7 +30,7 @@ impl VmDaemonServer {
#[tonic::async_trait]
impl BrainVmDaemon for VmDaemonServer {
type BrainMessagesStream = Pin<Box<dyn Stream<Item = Result<BrainVmMessage, Status>> + Send>>;
type RegisterVmNodeStream = Pin<Box<dyn Stream<Item = Result<VmContract, Status>> + Send>>;
type RegisterVmNodeStream = Pin<Box<dyn Stream<Item = Result<DeleteVmReq, Status>> + Send>>;
async fn register_vm_node(
&self,
@ -59,12 +59,12 @@ impl BrainVmDaemon for VmDaemonServer {
.register(&self.db)
.await?;
info!("Sending existing contracts to {}", req.node_pubkey);
let contracts = db::ActiveVmWithNode::list_by_node(&self.db, &req.node_pubkey).await?;
info!("Sending deleted contracts to {}", req.node_pubkey);
let deleted_vms = db::DeletedVm::list_by_node(&self.db, &req.node_pubkey).await?;
let (tx, rx) = mpsc::channel(6);
tokio::spawn(async move {
for contract in contracts {
let _ = tx.send(Ok(contract.into())).await;
for deleted_vm in deleted_vms {
let _ = tx.send(Ok(deleted_vm.into())).await;
}
});
let output_stream = ReceiverStream::new(rx);