Compare commits

..

1 Commits

Author SHA1 Message Date
813ad2aecd
add support for operators 2025-02-16 01:55:21 +02:00
2 changed files with 23 additions and 1 deletions

@ -295,7 +295,10 @@ impl BrainData {
Some(op) if op.escrow > 5000 => 5,
_ => 1,
};
self.add_nano_to_wallet(&operator_wallet, nanolp_to_collect * escrow_multiplier);
self.add_nano_to_wallet(
&operator_wallet,
nanolp_to_collect * escrow_multiplier,
);
if c.locked_nano == 0 {
deleted_contracts.push((c.uuid.clone(), c.node_pubkey.clone()));
}
@ -793,6 +796,17 @@ impl BrainData {
nodes.iter().cloned().find(|n| n.public_key == public_key)
}
pub fn is_user_banned_by_node(&self, user_wallet: &str, node_pubkey: &str) -> bool {
if let Some(node) = self.find_node_by_pubkey(&node_pubkey) {
if let Some(account) = self.accounts.get(user_wallet) {
if account.banned_by.contains(&node.operator_wallet) {
return true;
}
}
}
false
}
pub fn add_vmnode_to_operator(&self, operator_wallet: &str, node_pubkey: &str) {
self.operators
.entry(operator_wallet.to_string())

@ -160,6 +160,14 @@ impl BrainCli for BrainCliMock {
async fn new_vm(&self, req: Request<NewVmReq>) -> Result<Response<NewVmResp>, Status> {
let req = check_sig_from_req(req)?;
info!("New VM requested via CLI: {req:?}");
if self
.data
.is_user_banned_by_node(&req.admin_pubkey, &req.node_pubkey)
{
return Err(Status::permission_denied(
"This operator banned you. What did you do?",
));
}
let admin_pubkey = req.admin_pubkey.clone();
let (oneshot_tx, oneshot_rx) = tokio::sync::oneshot::channel();
self.data.submit_newvm_req(req, oneshot_tx).await;