Compare commits

..

1 Commits

Author SHA1 Message Date
2ed0501176
add support for operators 2025-02-14 04:19:48 +02:00

@ -751,12 +751,13 @@ impl BrainData {
if req.escrow < 5000 { if req.escrow < 5000 {
return Err(Error::MinimalEscrow); return Err(Error::MinimalEscrow);
} }
let escrow = req.escrow * 1_000_000_000;
if let Some(mut account) = self.accounts.get_mut(&req.pubkey) { if let Some(mut account) = self.accounts.get_mut(&req.pubkey) {
if (account.balance + operator.escrow) < req.escrow { if (account.balance + operator.escrow) < escrow {
return Err(Error::InsufficientFunds); return Err(Error::InsufficientFunds);
} }
account.balance = account.balance + operator.escrow - req.escrow; account.balance = account.balance + operator.escrow - escrow;
operator.escrow = req.escrow; operator.escrow = escrow;
} }
operator.email = req.email; operator.email = req.email;
self.operators.insert(req.pubkey, operator); self.operators.insert(req.pubkey, operator);
@ -859,7 +860,7 @@ impl BrainData {
.iter() .iter()
.map(|op| grpc::ListOperatorsResp { .map(|op| grpc::ListOperatorsResp {
pubkey: op.key().to_string(), pubkey: op.key().to_string(),
escrow: op.escrow, escrow: op.escrow / 1_000_000_000,
email: op.email.clone(), email: op.email.clone(),
app_nodes: 0, app_nodes: 0,
vm_nodes: op.vm_nodes.len() as u64, vm_nodes: op.vm_nodes.len() as u64,