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
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
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()
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()