Skip to content

Commit

Permalink
Fixed getting zone difficulty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Revertron committed Mar 17, 2021
1 parent 278f7a8 commit a4e9d92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion alfis.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Settings
origin = "00000087A1BA6F94781C77BBDA96CC548E1E7F502DB3EA3F103ACD9301813B43"
origin = "0000000D48E05DAB6B26C58094A2AF65563D1DB4EECAF18663B01CE77152E56B"
key_file = "default.key"
listen = "[::]:4244"
public = false
Expand Down
9 changes: 7 additions & 2 deletions src/web_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/webview/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}));
}
Expand Down

0 comments on commit a4e9d92

Please sign in to comment.