예제 #1
0
    def notify_block_new(self, block):
        """
        A new block was received and passed initial consensus validation
        in federation mode - send only own cluster's nodes
        """

        summary = hashlib.sha256()
        for batch in block.batches:
            summary.update(batch.header_signature.encode())

        LOGGER.debug(
            'ConsensusNotifier: notify_block_new BLOCK=%s SUMMARY=%s\n',
            block.header_signature[:8],
            summary.digest().hex()[:10])
        block_header = BlockHeader()
        block_header.ParseFromString(block.header)
        self._notify(
            validator_pb2.Message.CONSENSUS_NOTIFY_BLOCK_NEW,
            consensus_pb2.ConsensusNotifyBlockNew(
                block=consensus_pb2.ConsensusBlock(
                    block_id=bytes.fromhex(block.header_signature),
                    previous_id=bytes.fromhex(block_header.previous_block_id),
                    signer_id=bytes.fromhex(block_header.signer_public_key),
                    block_num=block_header.block_num,
                    payload=block_header.consensus,
                    summary=summary.digest())))
예제 #2
0
 def notify_block_new(self, block):
     """A new block was received and passed initial consensus validation"""
     summary = hashlib.sha256()
     for batch in block.batches:
         summary.update(batch.header_signature.encode())
     self._notify(
         validator_pb2.Message.CONSENSUS_NOTIFY_BLOCK_NEW,
         consensus_pb2.ConsensusNotifyBlockNew(
             block=consensus_pb2.ConsensusBlock(
                 block_id=bytes.fromhex(block.identifier),
                 previous_id=bytes.fromhex(block.previous_block_id),
                 signer_id=bytes.fromhex(block.header.signer_public_key),
                 block_num=block.block_num,
                 payload=block.consensus,
                 summary=summary.digest())))
예제 #3
0
 def notify_block_new(self, block):
     """A new block was received and passed initial consensus validation"""
     LOGGER.debug('ConsensusNotifier: NOTIFY BLOCK_NEW block=%s', block)
     summary = hashlib.sha256()
     for batch in block.batches:
         summary.update(batch.header_signature.encode())
     LOGGER.debug('ConsensusNotifier: NOTIFY BLOCK_NEW summary=%s block=%s',
                  summary, block)
     block_header = BlockHeader()
     block_header.ParseFromString(block.header)
     self._notify(
         validator_pb2.Message.CONSENSUS_NOTIFY_BLOCK_NEW,
         consensus_pb2.ConsensusNotifyBlockNew(
             block=consensus_pb2.ConsensusBlock(
                 block_id=bytes.fromhex(block.header_signature),
                 previous_id=bytes.fromhex(block_header.previous_block_id),
                 signer_id=bytes.fromhex(block_header.signer_public_key),
                 block_num=block_header.block_num,
                 payload=block_header.consensus,
                 summary=summary.digest())))