Example #1
0
 def commit(self) -> ResponseCommit:
     '''
     end_point = '/operator/commit'
     ret = request(end_point, 'POST')
     print(ret.text)
     worker = Thread(target=sign_apphash, args=[ret.text])
     worker.start()
     return ResponseCommit(data=bytes.fromhex(ret.text))
     '''
     if self.txIndex != 0:
         try:
             self.f1 = open(path1, 'a')
             self.f2 = open(path2, 'a')
         except:
             path1 = './time.txt'
             path2 = './num.txt'
             self.f1 = open(path1, 'a')
             self.f2 = open(path2, 'a')
             print("change path to current directory")
         self.f1.write(format(int(time.time()*1000)))
         self.f1.write('\n')
         self.f1.flush()
         self.f2.write(format(self.txIndex))
         self.f2.write('\n')
         self.f2.flush()
         
     #ret = [self.txIndex]
     self.txIndex = 0
     return ResponseCommit()#data=bytes(ret))
Example #2
0
 def commit(self):
     byte_length = max(ceil(self.state.size.bit_length() / 8), 1)
     app_hash = self.state.size.to_bytes(byte_length, byteorder='big')
     self.state.app_hash = app_hash
     self.state.height += 1
     self.state.save()
     return ResponseCommit(data=app_hash)
Example #3
0
 def commit(self) -> ResponseCommit:
     end_point = '/operator/commit'
     ret = request(end_point, 'POST')
     print(ret.text)
     worker = Thread(target=sign_apphash, args=[ret.text])
     worker.start()
     return ResponseCommit(data=bytes.fromhex(ret.text))
Example #4
0
    def commit(self):
        """Store the new height and along with block hash."""

        self.abort_if_abci_chain_is_not_synced()

        data = self.block_txn_hash.encode('utf-8')

        # register a new block only when new transactions are received
        if self.block_txn_ids:
            self.bigchaindb.store_bulk_transactions(self.block_transactions)

        block = Block(app_hash=self.block_txn_hash,
                      height=self.new_height,
                      transactions=self.block_txn_ids)
        # NOTE: storing the block should be the last operation during commit
        # this effects crash recovery. Refer BEP#8 for details
        self.bigchaindb.store_block(block._asdict())

        logger.debug(
            'Commit-ing new block with hash: apphash=%s ,'
            'height=%s, txn ids=%s', data, self.new_height, self.block_txn_ids)

        if self.events_queue:
            event = Event(EventTypes.BLOCK_VALID, {
                'height': self.new_height,
                'transactions': self.block_transactions
            })
            self.events_queue.put(event)

        return ResponseCommit(data=data)
Example #5
0
File: core.py Project: todun/vimana
 def commit(self):
     byte_length = max(ceil(self.state.size.bit_length() / 8), 1)
     app_hash = self.state.size.to_bytes(byte_length, byteorder='big')
     self.state.app_hash = app_hash
     self.state.height += 1
     self.state.save()
     logger.info("🦄 Yaasss! Transaction commit succesfully ")
     return ResponseCommit(data=app_hash)
Example #6
0
 def commit(self) -> ResponseCommit:
     """Return the current encode state value to tendermint"""
     log.info("Got Commit")
     hash = struct.pack('>Q', self.txCount)
     return ResponseCommit(data=hash)
Example #7
0
    def commit(self):
        """Return the current encode state value to tendermint"""

        h = self.db.get_block_app_hash().encode()

        return ResponseCommit(data=h)
Example #8
0
 def commit(self) -> ResponseCommit:
     return ResponseCommit(data=state_hash(self.state))