Decreased domain remining difficulty by 1.
This commit is contained in:
Generated
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aead"
|
name = "aead"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
@@ -65,7 +67,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alfis"
|
name = "alfis"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bincode",
|
"bincode",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alfis"
|
name = "alfis"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
authors = ["Revertron <alfis@revertron.com>"]
|
authors = ["Revertron <alfis@revertron.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ impl Chain {
|
|||||||
SIGNER_DIFFICULTY
|
SIGNER_DIFFICULTY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(t) => self.get_difficulty_for_transaction(&t)
|
Some(t) => self.get_difficulty_for_transaction(&t, block.index)
|
||||||
};
|
};
|
||||||
if block.difficulty < difficulty {
|
if block.difficulty < difficulty {
|
||||||
warn!("Block difficulty is lower than needed");
|
warn!("Block difficulty is lower than needed");
|
||||||
@@ -821,7 +821,7 @@ impl Chain {
|
|||||||
None => 0,
|
None => 0,
|
||||||
Some(block) => block.index
|
Some(block) => block.index
|
||||||
};
|
};
|
||||||
// If this domain is available to this public key
|
// If this domain is not available to this public key
|
||||||
if !self.is_id_available(current_height, &transaction.identity, &block.pub_key) {
|
if !self.is_id_available(current_height, &transaction.identity, &block.pub_key) {
|
||||||
warn!("Block {:?} is trying to spoof an identity!", &block);
|
warn!("Block {:?} is trying to spoof an identity!", &block);
|
||||||
return Bad;
|
return Bad;
|
||||||
@@ -959,11 +959,16 @@ impl Chain {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_difficulty_for_transaction(&self, transaction: &Transaction) -> u32 {
|
fn get_difficulty_for_transaction(&self, transaction: &Transaction, index: u64) -> u32 {
|
||||||
match transaction.class.as_ref() {
|
match transaction.class.as_ref() {
|
||||||
CLASS_DOMAIN => {
|
CLASS_DOMAIN => {
|
||||||
|
// If this domain is already in blockchain we approve slightly smaller difficulty
|
||||||
|
let discount = match self.is_domain_in_blockchain(index, &transaction.identity) {
|
||||||
|
true => { 1 }
|
||||||
|
false => { 0 }
|
||||||
|
};
|
||||||
return match serde_json::from_str::<DomainData>(&transaction.data) {
|
return match serde_json::from_str::<DomainData>(&transaction.data) {
|
||||||
Ok(_) => DOMAIN_DIFFICULTY,
|
Ok(_) => DOMAIN_DIFFICULTY - discount,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Error parsing DomainData from {:?}", transaction);
|
warn!("Error parsing DomainData from {:?}", transaction);
|
||||||
u32::MAX
|
u32::MAX
|
||||||
|
|||||||
+10
-2
@@ -560,7 +560,7 @@ fn format_event_now(kind: &str, message: &str) -> String {
|
|||||||
format!("addEvent('{}', '{}', '{}');", kind, time.format("%d.%m.%y %X"), message)
|
format!("addEvent('{}', '{}', '{}');", kind, time.format("%d.%m.%y %X"), message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_domain(_context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, class: &str, name: &str, mut data: DomainData, difficulty: u32, keystore: &Keystore, signing: Bytes, encryption: Bytes) {
|
fn create_domain(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, class: &str, name: &str, mut data: DomainData, difficulty: u32, keystore: &Keystore, signing: Bytes, encryption: Bytes) {
|
||||||
let name = name.to_owned();
|
let name = name.to_owned();
|
||||||
let encrypted = CryptoBox::encrypt(encryption.as_slice(), name.as_bytes()).expect("Error encrypting domain name!");
|
let encrypted = CryptoBox::encrypt(encryption.as_slice(), name.as_bytes()).expect("Error encrypting domain name!");
|
||||||
data.encrypted = Bytes::from_bytes(&encrypted);
|
data.encrypted = Bytes::from_bytes(&encrypted);
|
||||||
@@ -572,7 +572,15 @@ fn create_domain(_context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, class:
|
|||||||
(signing, encryption)
|
(signing, encryption)
|
||||||
};
|
};
|
||||||
let transaction = Transaction::from_str(name, class.to_owned(), data, signing, encryption);
|
let transaction = Transaction::from_str(name, class.to_owned(), data, signing, encryption);
|
||||||
let block = Block::new(Some(transaction), keystore.get_public(), Bytes::default(), difficulty);
|
// If this domain is already in blockchain we approve slightly smaller difficulty
|
||||||
|
let discount = {
|
||||||
|
let context = context.lock().unwrap();
|
||||||
|
match context.chain.is_domain_in_blockchain(context.chain.get_height(), &transaction.identity) {
|
||||||
|
true => { 1 }
|
||||||
|
false => { 0 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let block = Block::new(Some(transaction), keystore.get_public(), Bytes::default(), difficulty - discount);
|
||||||
miner.lock().unwrap().add_block(block, keystore.clone());
|
miner.lock().unwrap().add_block(block, keystore.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user