Compare commits

..

2 Commits

Author SHA1 Message Date
6a85acda9e
when node reconnects, send deleted VMs
previously, active VMs were sent
2025-05-20 01:45:31 +03:00
32b587c6c5
merged proto branch 2025-05-20 00:19:04 +03:00
3 changed files with 7 additions and 7 deletions

2
Cargo.lock generated

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

@ -13,7 +13,7 @@ serde_yaml = "0.9.34"
surrealdb = "2.2.2" surrealdb = "2.2.2"
tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread"] }
tonic = { version = "0.12", features = ["tls"] } tonic = { version = "0.12", features = ["tls"] }
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto", branch = "surreal_brain_app" } detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto", branch = "surreal_brain" }
ed25519-dalek = "2.1.1" ed25519-dalek = "2.1.1"
bs58 = "0.5.1" bs58 = "0.5.1"
tokio-stream = "0.1.17" tokio-stream = "0.1.17"

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