当前位置: 首页>>代码示例>>Python>>正文


Python Bigchain.is_valid_block方法代码示例

本文整理汇总了Python中bigchaindb.Bigchain.is_valid_block方法的典型用法代码示例。如果您正苦于以下问题:Python Bigchain.is_valid_block方法的具体用法?Python Bigchain.is_valid_block怎么用?Python Bigchain.is_valid_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bigchaindb.Bigchain的用法示例。


在下文中一共展示了Bigchain.is_valid_block方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import is_valid_block [as 别名]
    def validate(self):
        """
        Checks if incoming blocks are valid or not
        """

        # create a bigchain instance. All processes should create their own bigchcain instance so that they all
        # have their own connection to the database
        b = Bigchain()

        logger.info('voter waiting for new blocks')
        while True:
            new_block = self.q_blocks_to_validate.get()

            # poison pill
            if new_block == 'stop':
                self.q_validated_block.put('stop')
                return

            logger.info('new_block arrived to voter')
            block_number = self.v_previous_block_number.value + 1
            validity = b.is_valid_block(new_block)

            self.q_validated_block.put((new_block,
                                        self.v_previous_block_id.value.decode(),
                                        block_number,
                                        validity))

            self.v_previous_block_id.value = new_block['id'].encode()
            self.v_previous_block_number.value = block_number
开发者ID:benjaminbollen,项目名称:bigchaindb,代码行数:31,代码来源:voter.py

示例2: validate

# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import is_valid_block [as 别名]
    def validate(self):
        """
        Checks if incoming blocks are valid or not
        """

        # create a bigchain instance. All processes should create their own bigchcain instance so that they all
        # have their own connection to the database
        b = Bigchain()

        logger.info('voter waiting for new blocks')
        # signal initialization complete
        self.initialized.set()

        while True:
            new_block = self.q_blocks_to_validate.get()

            # poison pill
            if new_block == 'stop':
                self.q_validated_block.put('stop')
                return

            logger.info('new_block arrived to voter')

            with self.monitor.timer('validate_block'):
                # FIXME: the following check is done also in `is_valid_block`,
                #        but validity can be true even if the block has already
                #        a vote.
                if b.has_previous_vote(new_block):
                    continue
                validity = b.is_valid_block(new_block)

            self.q_validated_block.put((new_block,
                                        self.v_previous_block_id.value.decode(),
                                        validity))

            self.v_previous_block_id.value = new_block['id'].encode()
开发者ID:IoTCloudLab,项目名称:bigchaindb,代码行数:38,代码来源:voter.py


注:本文中的bigchaindb.Bigchain.is_valid_block方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。