Compare commits
1 Commits
89d40a07ee
...
af3c3103e2
Author | SHA1 | Date | |
---|---|---|---|
af3c3103e2 |
23
src/data.rs
23
src/data.rs
@ -218,7 +218,7 @@ impl BrainData {
|
||||
fn rm_nano_from_wallet(&self, account: &str, nano_lp: u64) {
|
||||
log::debug!("Adding {nano_lp} nanoLP to {account}");
|
||||
self.accounts.entry(account.to_string()).and_modify(|d| {
|
||||
let _ = d.balance.saturating_sub(nano_lp);
|
||||
d.balance.saturating_sub(nano_lp);
|
||||
});
|
||||
}
|
||||
|
||||
@ -335,27 +335,6 @@ impl BrainData {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn ban_user(&self, operator: &str, user: &str) {
|
||||
self.accounts
|
||||
.entry(user.to_string())
|
||||
.and_modify(|a| {
|
||||
a.banned_by.insert(operator.to_string());
|
||||
})
|
||||
.or_insert(AccountData {
|
||||
banned_by: HashSet::from([operator.to_string()]),
|
||||
..Default::default()
|
||||
});
|
||||
self.operators
|
||||
.entry(operator.to_string())
|
||||
.and_modify(|o| {
|
||||
o.banned_users.insert(user.to_string());
|
||||
})
|
||||
.or_insert(OperatorData {
|
||||
banned_users: HashSet::from([user.to_string()]),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
pub fn report_node(&self, admin_pubkey: String, node: &str, report: String) {
|
||||
let mut nodes = self.vm_nodes.write().unwrap();
|
||||
if let Some(node) = nodes.iter_mut().find(|n| n.public_key == node) {
|
||||
|
@ -313,12 +313,6 @@ impl BrainCli for BrainCliMock {
|
||||
}
|
||||
}
|
||||
|
||||
async fn ban_user(&self, req: Request<BanUserReq>) -> Result<Response<Empty>, Status> {
|
||||
let req = check_sig_from_req(req)?;
|
||||
self.data.ban_user(&req.operator_wallet, &req.user_wallet);
|
||||
Ok(Response::new(Empty {}))
|
||||
}
|
||||
|
||||
type ListOperatorsStream =
|
||||
Pin<Box<dyn Stream<Item = Result<ListOperatorsResp, Status>> + Send>>;
|
||||
async fn list_operators(
|
||||
@ -438,7 +432,6 @@ impl_pubkey_getter!(ListVmContractsReq, admin_pubkey);
|
||||
impl_pubkey_getter!(RegisterVmNodeReq, node_pubkey);
|
||||
impl_pubkey_getter!(RegOperatorReq, pubkey);
|
||||
impl_pubkey_getter!(KickReq, operator_wallet);
|
||||
impl_pubkey_getter!(BanUserReq, operator_wallet);
|
||||
|
||||
impl_pubkey_getter!(VmNodeFilters);
|
||||
impl_pubkey_getter!(Empty);
|
||||
|
7
vm.proto
7
vm.proto
@ -239,11 +239,6 @@ message KickReq {
|
||||
string reason = 3;
|
||||
}
|
||||
|
||||
message BanUserReq {
|
||||
string operator_wallet = 1;
|
||||
string user_wallet = 2;
|
||||
}
|
||||
|
||||
service BrainCli {
|
||||
rpc GetBalance (Pubkey) returns (AccountBalance);
|
||||
rpc NewVm (NewVmReq) returns (NewVmResp);
|
||||
@ -258,7 +253,7 @@ service BrainCli {
|
||||
rpc InspectOperator (Pubkey) returns (InspectOperatorResp);
|
||||
rpc RegisterOperator (RegOperatorReq) returns (Empty);
|
||||
rpc KickContract (KickReq) returns (Empty);
|
||||
rpc BanUser (BanUserReq) returns (Empty);
|
||||
rpc BanUser (Pubkey) returns (Empty);
|
||||
// admin commands
|
||||
rpc Airdrop (AirdropReq) returns (Empty);
|
||||
rpc Slash (SlashReq) returns (Empty);
|
||||
|
Loading…
Reference in New Issue
Block a user