Added some checks to prevent user from mining if last full block is not signed enough.
This commit is contained in:
@@ -234,6 +234,17 @@ impl Chain {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_waiting_signers(&self) -> bool {
|
||||
if let Some(full_block) = &self.last_full_block {
|
||||
let sign_count = self.height() - full_block.index;
|
||||
if sign_count < BLOCK_SIGNERS_MIN {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn delete_transaction(&mut self, index: u64) -> sqlite::Result<()> {
|
||||
let mut statement = self.db.prepare(SQL_DELETE_DOMAIN)?;
|
||||
statement.bind(1, index as i64)?;
|
||||
|
||||
@@ -357,6 +357,11 @@ fn action_create_domain(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>,
|
||||
show_warning(web_view, "You don't have keys loaded!<br>Load or mine the keys and try again.");
|
||||
return;
|
||||
}
|
||||
if context.chain.is_waiting_signers() {
|
||||
show_warning(web_view, "Waiting for last full block to be signed. Try again later.");
|
||||
info!("Waiting for last full block to be signed. Try again later.");
|
||||
return;
|
||||
}
|
||||
let keystore = context.get_keystore().unwrap();
|
||||
let pub_key = keystore.get_public();
|
||||
let mut data = match serde_json::from_str::<DomainData>(&data) {
|
||||
@@ -407,6 +412,12 @@ fn action_create_domain(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>,
|
||||
}
|
||||
|
||||
fn action_create_zone(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, web_view: &mut WebView<()>, name: String, data: String) {
|
||||
if context.lock().unwrap().chain.is_waiting_signers() {
|
||||
show_warning(web_view, "Waiting for last full block to be signed. Try again later.");
|
||||
info!("Waiting for last full block to be signed. Try again later.");
|
||||
return;
|
||||
}
|
||||
|
||||
let name = name.to_lowercase();
|
||||
if name.len() > ZONE_MAX_LENGTH || !check_domain(&name, false) || context.lock().unwrap().x_zones.has_zone(&name) {
|
||||
warn!("This zone is unavailable for mining!");
|
||||
|
||||
Reference in New Issue
Block a user