2
0
mirror of https://github.com/Revertron/Alfis synced 2024-11-03 15:40:19 +00:00

Fixed getting zone difficulty.

This commit is contained in:
Revertron 2021-03-17 20:05:05 +01:00
parent 278f7a8c34
commit a4e9d92680
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# Settings
origin = "00000087A1BA6F94781C77BBDA96CC548E1E7F502DB3EA3F103ACD9301813B43"
origin = "0000000D48E05DAB6B26C58094A2AF65563D1DB4EECAF18663B01CE77152E56B"
key_file = "default.key"
listen = "[::]:4244"
public = false

View File

@ -19,7 +19,7 @@ use alfis::event::Event;
use alfis::dns::protocol::DnsRecord;
use alfis::blockchain::{ZONE_MAX_LENGTH, ZONE_DIFFICULTY};
use Cmd::*;
use alfis::blockchain::transaction::DomainData;
use alfis::blockchain::transaction::{DomainData, ZoneData};
pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>) {
let file_content = include_str!("webview/index.html");
@ -166,7 +166,7 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>) {
let data = DomainData::new(zone.clone(), records);
let (keystore, transaction, difficulty) = {
let context = context.lock().unwrap();
(context.get_keystore(), context.chain.get_domain_transaction(&name), context.chain.get_zone_difficulty(&name))
(context.get_keystore(), context.chain.get_domain_transaction(&name), context.chain.get_zone_difficulty(&zone))
};
let data = serde_json::to_string(&data).unwrap();
match transaction {
@ -210,6 +210,11 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>) {
return Ok(());
}
let data = data.to_lowercase();
if serde_json::from_str::<ZoneData>(&data).is_err() {
warn!("Something wrong with zone data!");
let _ = web_view.eval(&format!("showWarning('{}');", "Something wrong with zone data!"));
return Ok(());
}
let (keystore, transaction) = {
let context = context.lock().unwrap();
(context.get_keystore(), context.chain.get_domain_transaction(&name))

View File

@ -136,7 +136,7 @@ function createZone() {
difficulty = document.getElementById("new_zone_difficulty").value;
obj = {};
obj.name = new_zone;
obj.difficulty = difficulty;
obj.difficulty = parseInt(difficulty);
data = JSON.stringify(obj);
external.invoke(JSON.stringify({cmd: 'createZone', name: new_zone, data: data}));
}