Browse Source

upgrade deps

pull/18/head
Sun 4 years ago
parent
commit
9c8b1b7cae
  1. 11
      Cargo.toml
  2. 9
      README.md
  3. 12
      src/apps/wallet/models.rs
  4. 23
      src/apps/wallet/rpc.rs
  5. 18
      src/utils/device_status.rs

11
Cargo.toml

@ -23,14 +23,15 @@ panic = 'abort' @@ -23,14 +23,15 @@ panic = 'abort'
anyhow = "1.0"
log = "0.4"
rand = "0.8"
once_cell = "1.7"
simplelog = "=0.10.0"
once_cell = "1.8"
simplelog = "0.11"
image = "0.23"
base64 = "0.13"
blake3 = "0.3"
sha2 = "0.10"
blake3 = "1.2"
bincode = "1.3"
aes-gcm = "0.8"
sysinfo = "0.16"
aes-gcm = "0.9"
sysinfo = "0.21"
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
web3 = { version = "0.17", default-features = false, features = ["http-tls", "signing"] }

9
README.md

@ -1,13 +1,16 @@ @@ -1,13 +1,16 @@
# ESSE
<h1 align="center"><img src="https://cympletech.com/screenshots/esse_words_logo.png" alt="ESSE"></h1>
**ESSE** (Encrypted Symmetrical Session Engine) An open source encrypted peer-to-peer session system would allow data to be sent securely from one terminal to another without going through third-party services.
**ESSE** (Encrypted Symmetrical Session Engine) An open source encrypted peer-to-peer system for data security, would allow data to be sent securely from one terminal to another without going through third-party services.
**Protect your own data, protect your own privacy.**
![image](https://cympletech.com/statics/esse-show.gif)
ESSE, stands for Encrypted Symmetrical Session Engine, positioned as an engine. The engine is coded in [**Rust**](https://github.com/rust-lang/rust) language based on [**TDN**](https://github.com/cypherlink/TDN) framework, and the cross-platform user interface is built using [**Flutter**](https://github.com/flutter/flutter).
## Features
- Data Fortress
- Data Security Fortress
- Encryption Everywhere
- Distributed Identity
- Distributed Devices
- Distributed Notes & Files

12
src/apps/wallet/models.rs

@ -183,6 +183,18 @@ impl Address { @@ -183,6 +183,18 @@ impl Address {
}
}
pub fn import(chain: ChainToken, address: String, secret: String) -> Self {
Self {
name: format!("Import {}", &address[2..4]),
chain,
address,
secret,
index: 0,
balance: "".to_owned(),
id: 0,
}
}
pub fn to_rpc(&self) -> RpcParam {
json!([
self.id,

23
src/apps/wallet/rpc.rs

@ -5,7 +5,7 @@ use tdn::types::{ @@ -5,7 +5,7 @@ use tdn::types::{
primitive::{HandleResult, Result},
rpc::{json, rpc_response, RpcError, RpcHandler, RpcParam},
};
use tdn_did::{generate_btc_account, generate_eth_account};
use tdn_did::{generate_btc_account, generate_eth_account, secp256k1::SecretKey};
use tdn_storage::local::DStorage;
use tokio::sync::mpsc::Sender;
use web3::signing::Key;
@ -141,6 +141,27 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) { @@ -141,6 +141,27 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) {
},
);
handler.add_method(
"wallet-import",
|gid: GroupId, params: Vec<RpcParam>, state: Arc<RpcState>| async move {
let chain = ChainToken::from_i64(params[0].as_i64().ok_or(RpcError::ParseError)?);
let _lock = params[1].as_str().ok_or(RpcError::ParseError)?;
let secret = params[2].as_str().ok_or(RpcError::ParseError)?;
let sk: SecretKey = secret.parse().or(Err(RpcError::ParseError))?;
let addr = format!("{:?}", (&sk).address());
let group_lock = state.group.read().await;
let encrypt_secret = "".to_owned();
let db = wallet_db(group_lock.base(), &gid)?;
drop(group_lock);
let mut address = Address::import(chain, addr, encrypt_secret);
address.insert(&db)?;
Ok(HandleResult::rpc(address.to_rpc()))
},
);
handler.add_method(
"wallet-balance",
|gid: GroupId, params: Vec<RpcParam>, state: Arc<RpcState>| async move {

18
src/utils/device_status.rs

@ -6,23 +6,23 @@ use sysinfo::{DiskExt, ProcessorExt, System, SystemExt}; @@ -6,23 +6,23 @@ use sysinfo::{DiskExt, ProcessorExt, System, SystemExt};
/// only 4-length number, max is 9999 (99.99%), min is 0 (0.00%)
pub(crate) fn device_status() -> (u32, u32, u32, u32, u16, u16, u16, u16) {
let s = System::new_all();
let cpu_n = s.get_physical_core_count().unwrap_or(0) as u32;
let cpu = s.get_global_processor_info().get_cpu_usage();
let cpu_n = s.physical_core_count().unwrap_or(0) as u32;
let cpu = s.global_processor_info().cpu_usage();
let cpu_p = (cpu * 100f32) as u16;
let memory_t = (s.get_total_memory() / 1024) as u32; // MB
let memory_u = (s.get_used_memory() / 1024) as f32;
let memory_t = (s.total_memory() / 1024) as u32; // MB
let memory_u = (s.used_memory() / 1024) as f32;
let memory_p = (memory_u / memory_t as f32 * 10000f32) as u16;
let swap_t = (s.get_total_swap() / 1024) as u32;
let swap_u = (s.get_used_swap() / 1024) as f32;
let swap_t = (s.total_swap() / 1024) as u32;
let swap_u = (s.used_swap() / 1024) as f32;
let swap_p = (swap_u / swap_t as f32 * 10000f32) as u16;
let mut disk_t = 0;
let mut disk_a = 0;
for disk in s.get_disks() {
disk_t += disk.get_total_space();
disk_a += disk.get_available_space();
for disk in s.disks() {
disk_t += disk.total_space();
disk_a += disk.available_space();
}
let disk_t_n = (disk_t / 1048576) as u32;
let disk_t_f = disk_t_n as f32;

Loading…
Cancel
Save