Compare commits

..

1 Commits

Author SHA1 Message Date
c7cd30b2e0
add support for operators 2025-02-14 04:12:51 +02:00

@ -751,13 +751,12 @@ 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) < escrow { if (account.balance + operator.escrow) < req.escrow {
return Err(Error::InsufficientFunds); return Err(Error::InsufficientFunds);
} }
account.balance = account.balance + operator.escrow - escrow; account.balance = account.balance + operator.escrow - req.escrow;
operator.escrow = escrow; operator.escrow = req.escrow;
} }
operator.email = req.email; operator.email = req.email;
self.operators.insert(req.pubkey, operator); self.operators.insert(req.pubkey, operator);
@ -860,7 +859,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 / 1_000_000_000, escrow: op.escrow,
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,