Просмотр исходного кода

consensus: Add debug message to ProtocolSync when a block is appended.

parazyd 4 лет назад
Родитель
Сommit
2667bd9e06
2 измененных файлов с 5 добавлено и 4 удалено
  1. 4 4
      src/blockchain/mod.rs
  2. 1 0
      src/consensus2/proto/protocol_sync.rs

+ 4 - 4
src/blockchain/mod.rs

@@ -110,10 +110,10 @@ impl Blockchain {
 
     /// Check if the given [`BlockInfo`] is in the database
     pub fn has_block(&self, info: &BlockInfo) -> Result<bool> {
-        let hashes = self.order.get(&[info.sl], true)?;
-        if hashes.is_empty() {
-            return Ok(false)
-        }
+        let hashes = match self.order.get(&[info.sl], true) {
+            Ok(v) => v,
+            Err(_) => return Ok(false),
+        };
 
         if let Some(found) = &hashes[0] {
             // Check provided info produces the same hash

+ 1 - 0
src/consensus2/proto/protocol_sync.rs

@@ -88,6 +88,7 @@ impl ProtocolSync {
             if !self.consensus_mode {
                 let info_copy = (*info).clone();
                 if !self.state.read().await.blockchain.has_block(&info_copy)? {
+                    debug!("ProtocolSync::handle_receive_block(): Appending block to ledger");
                     self.state.write().await.blockchain.add(&[info_copy.clone()])?;
                     self.state.write().await.remove_txs(info_copy.txs.clone())?;
                     self.p2p.broadcast(info_copy).await?;