Procházet zdrojové kódy

[research/ouroboros] Z blockchain printing

mohab před 4 roky
rodič
revize
237b71353d

+ 1 - 1
script/research/dpos/ouroboros/blockchain.py

@@ -36,7 +36,7 @@ class Blockchain(object):
             if not block.empty:
                 self.__add_block(block)
             else:
-                self.log.info(f"met an empty block at index of index: {block.index},\nrelative slot:{idx}\nabsolute slot: {self.length*idx+block.slot}")
+                self.log.warn(f"an empty block at index of index: {block.index},\nrelative slot:{idx}\nabsolute slot: {self.length*idx+block.slot}")
 
 
     

+ 4 - 3
script/research/dpos/ouroboros/environment.py

@@ -124,13 +124,14 @@ class Z(object):
         for stakeholder in self.stakeholders:
             if not stakeholder.is_leader:
                 stakeholder.receive_block(signed_block, slot_uid)
+        self.print_blockchain()
 
     def start(self):
         for sh in self.stakeholders:
             sh(self)
-        for sh in self.stakeholders:
             sh.start()
 
     def print_blockchain(self):
-        bc = self.stakeholders[0].blockchain
-        self.log.highlight(f"<blockchain>  {len(bc)} blocks: "+str(bc))
+        for sh in self.stakeholders:
+            bc = sh.blockchain
+            self.log.highlight(f"<blockchain>  {len(bc)} blocks: "+str(bc))

+ 0 - 2
script/research/dpos/ouroboros/stakeholder.py

@@ -147,7 +147,6 @@ class Stakeholder(object):
         assert(self.am_current_leader and self.current_block is not None)
         signed_block = sign_message(self.passwd, self.sig_sk, self.current_block)
         self.env.broadcast_block(signed_block, self.current_slot_uid)
-        self.env.print_blockchain()
 
     def receive_block(self, signed_block, blk_uid):
         self.log.highlight("receiving block")
@@ -166,4 +165,3 @@ class Stakeholder(object):
                 self.current_epoch.add_block(cur_blk)
         else:
             self.env.corrupt(self.env.current_leader_id)
-        self.env.print_blockchain()