Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Nov 26, 2024
1 parent b29e584 commit e647135
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 90 deletions.
3 changes: 0 additions & 3 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ where S: ShareChain

/// Broadcasting a new mined [`Block`] to the network (assume it is already validated with the network).
async fn broadcast_block(&mut self, result: Result<NotifyNewTipBlock, RecvError>) {
dbg!("Broadcast block");
// if self.sync_in_progress.load(Ordering::SeqCst) {
// return;
// }
Expand Down Expand Up @@ -1702,8 +1701,6 @@ where S: ShareChain
}

async fn attempt_relay_reservation(&mut self) {
dbg!("Attempt relay reservation");

// Can happen that a previous lock already set the relaty
if self.swarm.external_addresses().count() > 0 {
warn!(target: LOG_TARGET, "No need to relay, we have an external address or relay already");
Expand Down
12 changes: 6 additions & 6 deletions src/sharechain/p2block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,10 @@ impl P2BlockBuilder {
}

pub fn build(mut self) -> Result<Arc<P2Block>, ShareChainError> {
if !self.use_specific_hash {
self.block.hash = self.block.generate_hash();
}
if !self.added_target_difficulty {
if !self.added_target_difficulty || self.block.prev_hash == BlockHash::zero() {
if self.block.prev_hash == BlockHash::zero() {
self.block.total_pow = AccumulatedDifficulty::from_u128(self.block.target_difficulty.as_u64() as u128).map_err(|_| ShareChainError::DifficultyOverflow)?;
self.block.total_pow = AccumulatedDifficulty::from_u128(self.block.target_difficulty.as_u64() as u128)
.map_err(|_| ShareChainError::DifficultyOverflow)?;
} else {
self.block.total_pow = self
.block
Expand All @@ -217,7 +215,9 @@ impl P2BlockBuilder {
.ok_or(ShareChainError::DifficultyOverflow)?;
}
}
dbg!(self.block.total_pow);
if !self.use_specific_hash {
self.block.hash = self.block.generate_hash();
}
Ok(Arc::new(self.block))
}
}
Loading

0 comments on commit e647135

Please sign in to comment.