Stability fixes.
This commit is contained in:
+12
-9
@@ -254,17 +254,20 @@ impl Chain {
|
|||||||
let index = block.index;
|
let index = block.index;
|
||||||
let timestamp = block.timestamp;
|
let timestamp = block.timestamp;
|
||||||
let owner = block.pub_key.clone();
|
let owner = block.pub_key.clone();
|
||||||
self.last_block = Some(block.clone());
|
|
||||||
if block.transaction.is_some() {
|
|
||||||
self.last_full_block = Some(block.clone());
|
|
||||||
}
|
|
||||||
let transaction = block.transaction.clone();
|
let transaction = block.transaction.clone();
|
||||||
if self.add_block_to_table(block).is_ok() {
|
match self.add_block_to_table(block.clone()) {
|
||||||
if let Some(mut transaction) = transaction {
|
Ok(_) => {
|
||||||
if transaction.signing.is_empty() {
|
self.last_block = Some(block.clone());
|
||||||
transaction.signing = owner;
|
if let Some(mut transaction) = transaction {
|
||||||
|
self.last_full_block = Some(block);
|
||||||
|
if transaction.signing.is_empty() {
|
||||||
|
transaction.signing = owner;
|
||||||
|
}
|
||||||
|
self.add_transaction_to_table(index, timestamp, &transaction).expect("Error adding transaction");
|
||||||
}
|
}
|
||||||
self.add_transaction_to_table(index, timestamp, &transaction).expect("Error adding transaction");
|
}
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Error adding block to table ({}): {:?}", e, &block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -288,8 +288,12 @@ impl Peers {
|
|||||||
|
|
||||||
// If someone has more blocks we sync
|
// If someone has more blocks we sync
|
||||||
if nodes >= MIN_CONNECTED_NODES_START_SYNC && height < max_height {
|
if nodes >= MIN_CONNECTED_NODES_START_SYNC && height < max_height {
|
||||||
let count = min(max_height - height, nodes as u64);
|
// Give some opportunity to get more peers instead of requests for blocks only
|
||||||
self.ask_blocks_from_peers(registry, height, height + count, have_blocks);
|
let request_blocks = nodes >= 10 || random::<bool>();
|
||||||
|
if request_blocks {
|
||||||
|
let count = min(max_height - height, nodes as u64);
|
||||||
|
self.ask_blocks_from_peers(registry, height, height + count, have_blocks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If someone has less blocks (we mined a new block) we send a ping with our height
|
// If someone has less blocks (we mined a new block) we send a ping with our height
|
||||||
|
|||||||
Reference in New Issue
Block a user