Stability fixes.
This commit is contained in:
@@ -254,19 +254,22 @@ impl Chain {
|
||||
let index = block.index;
|
||||
let timestamp = block.timestamp;
|
||||
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();
|
||||
if self.add_block_to_table(block).is_ok() {
|
||||
match self.add_block_to_table(block.clone()) {
|
||||
Ok(_) => {
|
||||
self.last_block = Some(block.clone());
|
||||
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");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Error adding block to table ({}): {:?}", e, &block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_block(&mut self, block: Block) -> sqlite::Result<()> {
|
||||
|
||||
@@ -288,9 +288,13 @@ impl Peers {
|
||||
|
||||
// If someone has more blocks we sync
|
||||
if nodes >= MIN_CONNECTED_NODES_START_SYNC && height < max_height {
|
||||
// Give some opportunity to get more peers instead of requests for blocks only
|
||||
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 self.need_behind_ping() {
|
||||
|
||||
Reference in New Issue
Block a user