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.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aead"
|
||||
version = "0.3.2"
|
||||
@@ -65,7 +67,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "alfis"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bincode",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "alfis"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
authors = ["Revertron <alfis@revertron.com>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
@@ -785,7 +785,7 @@ impl Chain {
|
||||
SIGNER_DIFFICULTY
|
||||
}
|
||||
}
|
||||
Some(t) => self.get_difficulty_for_transaction(&t)
|
||||
Some(t) => self.get_difficulty_for_transaction(&t, block.index)
|
||||
};
|
||||
if block.difficulty < difficulty {
|
||||
warn!("Block difficulty is lower than needed");
|
||||
@@ -821,7 +821,7 @@ impl Chain {
|
||||
None => 0,
|
||||
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) {
|
||||
warn!("Block {:?} is trying to spoof an identity!", &block);
|
||||
return Bad;
|
||||
@@ -959,11 +959,16 @@ impl Chain {
|
||||
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() {
|
||||
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) {
|
||||
Ok(_) => DOMAIN_DIFFICULTY,
|
||||
Ok(_) => DOMAIN_DIFFICULTY - discount,
|
||||
Err(_) => {
|
||||
warn!("Error parsing DomainData from {:?}", transaction);
|
||||
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)
|
||||
}
|
||||
|
||||
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 encrypted = CryptoBox::encrypt(encryption.as_slice(), name.as_bytes()).expect("Error encrypting domain name!");
|
||||
data.encrypted = Bytes::from_bytes(&encrypted);
|
||||
@@ -572,7 +572,15 @@ fn create_domain(_context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, class:
|
||||
(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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user