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