fix list-users

Niko PLP 1 year ago
parent d386d134d0
commit 29b5e5febb
  1. 7
      ngcli/src/main.rs
  2. 7
      p2p-broker/src/broker_store/account.rs

@ -116,7 +116,8 @@ async fn main() -> Result<(), ProtocolError> {
.arg( .arg(
arg!( arg!(
-s --server <IP_PORT_PEER_ID> "Server to connect to. IP can be IpV4 or IPv6, followed by a -s --server <IP_PORT_PEER_ID> "Server to connect to. IP can be IpV4 or IPv6, followed by a
comma and port as u16 and another comma and PEER_ID should be a base64-url encoded serde serialization of a [u8; 32]" comma and port as u16 and another comma and PEER_ID
should be a base64-url encoded serde serialization of a [u8; 32]"
) )
.required(false) .required(false)
.env("NG_CLIENT_SERVER"), .env("NG_CLIENT_SERVER"),
@ -320,7 +321,7 @@ async fn main() -> Result<(), ProtocolError> {
ProtocolError::InvalidValue ProtocolError::InvalidValue
})?; })?;
if config.is_some() { if config.is_some() {
log_warn!("Overwriting the config found in file with new server parameters provided on command line!"); log_warn!("Overriding the config found in file with new server parameters provided on command line!");
let CliConfig::V0(c) = config.as_mut().unwrap(); let CliConfig::V0(c) = config.as_mut().unwrap();
c.ip = ip; c.ip = ip;
c.port = port; c.port = port;
@ -349,7 +350,7 @@ async fn main() -> Result<(), ProtocolError> {
if config.is_some() { if config.is_some() {
let CliConfig::V0(c) = config.as_mut().unwrap(); let CliConfig::V0(c) = config.as_mut().unwrap();
if c.user.is_some() { if c.user.is_some() {
log_warn!("Overwriting the config found in file with new user parameter provided on command line!"); log_warn!("Overriding the config found in file with new user parameter provided on command line!");
} }
c.user = Some(privkey); c.user = Some(privkey);
} else { } else {

@ -16,6 +16,7 @@ use std::time::SystemTime;
use p2p_net::types::*; use p2p_net::types::*;
use p2p_repo::kcv_store::KCVStore; use p2p_repo::kcv_store::KCVStore;
use p2p_repo::log::*;
use p2p_repo::store::*; use p2p_repo::store::*;
use p2p_repo::types::Timestamp; use p2p_repo::types::Timestamp;
use serde_bare::{from_slice, to_vec}; use serde_bare::{from_slice, to_vec};
@ -71,7 +72,7 @@ impl<'a> Account<'a> {
for user in store.get_all_keys_and_values(Self::PREFIX_ACCOUNT, size, vec![], None)? { for user in store.get_all_keys_and_values(Self::PREFIX_ACCOUNT, size, vec![], None)? {
let admin: bool = from_slice(&user.1)?; let admin: bool = from_slice(&user.1)?;
if admin == admins { if admin == admins {
let id: UserId = from_slice(&user.0[1..user.0.len() - 1])?; let id: UserId = from_slice(&user.0[1..user.0.len()])?;
res.push(id); res.push(id);
} }
} }
@ -226,7 +227,7 @@ mod test {
use p2p_repo::types::*; use p2p_repo::types::*;
use p2p_repo::utils::*; use p2p_repo::utils::*;
use std::fs; use std::fs;
use stores_lmdb::kcv_store::LmdbKCVStore; use stores_rocksdb::kcv_store::RocksdbKCVStore;
use tempfile::Builder; use tempfile::Builder;
use crate::broker_store::account::Account; use crate::broker_store::account::Account;
@ -238,7 +239,7 @@ mod test {
let key: [u8; 32] = [0; 32]; let key: [u8; 32] = [0; 32];
fs::create_dir_all(root.path()).unwrap(); fs::create_dir_all(root.path()).unwrap();
println!("{}", root.path().to_str().unwrap()); println!("{}", root.path().to_str().unwrap());
let mut store = LmdbKCVStore::open(root.path(), key).unwrap(); let mut store = RocksdbKCVStore::open(root.path(), key).unwrap();
let user_id = PubKey::Ed25519PubKey([1; 32]); let user_id = PubKey::Ed25519PubKey([1; 32]);

Loading…
Cancel
Save