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


Python Uint256.zero方法代码示例

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


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

示例1: test_serialize_getblocks_message

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def test_serialize_getblocks_message(self):
     getblocks_msg = GetblocksMessage(BlockLocator(32200,
                                                   [Uint256.from_hexstr("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")]), 
                                      Uint256.zero())
     
     serialized_msg = GetblocksMessageSerializer().serialize(getblocks_msg)
     self.assertEquals(hexstr(serialized_msg), "c87d0000016fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900000000000000000000000000000000000000000000000000000000000000000000000000")
开发者ID:sirk390,项目名称:coinpy,代码行数:9,代码来源:test_messages.py

示例2: get_next_in_mainchain

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def get_next_in_mainchain(self, blockhash):
     if not self.indexdb.contains_block(blockhash):
         raise BlockNotFound(str(blockhash))
     blockindex = self.indexdb.get_blockindex(blockhash)
     if (blockindex.hash_next == Uint256.zero()):
         return None
     return blockindex.hash_next
开发者ID:sirk390,项目名称:coinpy,代码行数:9,代码来源:db_blockchain.py

示例3: _find_fork

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def _find_fork(self, altchainhash):
     hash = altchainhash
     while hash != Uint256.zero():
         handle = self.get_block_handle(hash)
         if handle.is_mainchain():
             return hash
         hash = handle.get_blockheader().hash_prev 
     return handle.hash
开发者ID:sirk390,项目名称:coinpy,代码行数:10,代码来源:db_blockchain.py

示例4: append_block

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def append_block(self, blockhash, block):
     file, blockpos = self.blockstore.saveblock(block)
     prevblock = self.get_block_handle(block.blockheader.hash_prev)
     
     idx = DbBlockIndex(self.version, Uint256.zero(), file, blockpos, prevblock.get_height()+1, block.blockheader)
     self.indexdb.set_blockindex(blockhash, idx)
     if prevblock.hash == self.get_mainchain():
         prevblock.blockindex.hash_next = blockhash
         self.indexdb.set_blockindex(prevblock.hash, prevblock.blockindex)
         self.indexdb.set_hashbestchain(blockhash)
         self._index_transactions(blockhash, block)
     return DBBlockHandle(self.log, self.indexdb, self.blockstore, blockhash, block=block)
开发者ID:sirk390,项目名称:coinpy,代码行数:14,代码来源:db_blockchain.py

示例5: send_transaction

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
    def send_transaction(self, planned_tx, passphrases):
        try:
            self.wallet.unlock(passphrases)
            privkey_list = []
            for outpoint, txout in planned_tx.selected_outputs:
                privkey_list.append(self.wallet.get_txout_private_key_secret(txout))
        finally:
            self.wallet.lock()
        sign_transaction(planned_tx.tx, [txout for outpoint, txout in planned_tx.selected_outputs], privkey_list)
        txhash = hash_tx(planned_tx.tx)
        self.log.info(
            "Sending %f to %s (fee:%f), change address: %s, hash:%s"
            % (planned_tx.amount, str(planned_tx.address), planned_tx.fee, str(planned_tx.change_address), str(txhash))
        )
        # Initially, create an empty MerkleTx (the tx is not yet in a block)
        merkle_tx = MerkleTx(planned_tx.tx, Uint256.zero(), [], 4294967295)
        self.wallet.begin_updates()
        self.wallet.allocate_key(planned_tx.change_public_key, ischange=True)
        # Set the spend flags for the input transactions
        for outpoint, txout in planned_tx.selected_outputs:
            input_wallet_tx = self.wallet.get_transaction(outpoint.hash)
            input_wallet_tx.set_spent(outpoint.index)
            self.wallet.set_transaction(outpoint.hash, input_wallet_tx)
        # Add the wallet_tx (contains supporting transations)
        txtime = int(time.time())
        wallet_tx = create_wallet_tx(self.blockchain, merkle_tx, txtime)
        self.wallet.add_transaction(txhash, wallet_tx)
        self.wallet.commit_updates()
        self.fire(
            self.EVT_NEW_TRANSACTION_ITEM,
            item=(planned_tx.tx, txhash, txtime, planned_tx.address, "", -planned_tx.amount, False),
        )

        self.compute_balances()  # we could only compute delta here
        self.fire(self.EVT_PUBLISH_TRANSACTION, txhash=txhash, tx=planned_tx.tx)
        self.last_tx_publish[txhash] = txtime
        # update description of change address
        new_description = self.wallet.get_address_description(planned_tx.change_public_key)
        self.fire(
            self.EVT_NEW_ADDRESS_DESCRIPTION, public_key=planned_tx.change_public_key, description=new_description
        )
开发者ID:sirk390,项目名称:coinpy,代码行数:43,代码来源:wallet_account.py

示例6: is_null

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def is_null(self):
     return (self.hash == Uint256.zero() and self.index == NULL_OUTPOINT_INDEX)
开发者ID:sirk390,项目名称:coinpy,代码行数:4,代码来源:outpoint.py

示例7: null

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def null():
     return (Outpoint(Uint256.zero(), NULL_OUTPOINT_INDEX))
开发者ID:sirk390,项目名称:coinpy,代码行数:4,代码来源:outpoint.py

示例8: check_proof_of_work

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def check_proof_of_work(self, hash, block):
     target = block.blockheader.target()
     if (target <= Uint256.zero() or target > PROOF_OF_WORK_LIMIT[self.runmode]):
         raise Exception("proof of work: value out of range : %x" % (block.blockheader.bits))
     if (hash > target):
         raise Exception("proof of work: hash doesn't match target hash:%s, target:%s" % (hash, target))
开发者ID:sirk390,项目名称:coinpy,代码行数:8,代码来源:block_checks.py

示例9: hasprev

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def hasprev(self):
     return self.blockindex.blockheader.hash_prev != Uint256.zero()
开发者ID:sirk390,项目名称:coinpy,代码行数:4,代码来源:db_blockhandle.py

示例10: is_mainchain

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def is_mainchain(self):
     return (self.blockindex.hash_next != Uint256.zero() or 
             self.hash == self.indexdb.get_hashbestchain())
开发者ID:sirk390,项目名称:coinpy,代码行数:5,代码来源:db_blockhandle.py

示例11: create

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def create(self, genesis_block):
     file, blockpos = self.blockstore.saveblock(genesis_block)
     self.blockstore.commit()
     genesis_index = DbBlockIndex(self.version, Uint256.zero(), file, blockpos, 0, genesis_block.blockheader)
     self.indexdb.create(hash_block(genesis_block), genesis_index)
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:db_blockchain.py

示例12: on_version_exchange

# 需要导入模块: from coinpy.model.protocol.structures.uint256 import Uint256 [as 别名]
# 或者: from coinpy.model.protocol.structures.uint256.Uint256 import zero [as 别名]
 def on_version_exchange(self, event):
     peer_heigth = event.version_message.start_height
     my_height = self.blockchain.get_height()
     if (peer_heigth > my_height and self.firstrequest):
         self.push_getblocks(event.handler, Uint256.zero())
         self.firstrequest = False
开发者ID:sirk390,项目名称:coinpy,代码行数:8,代码来源:blockchain_downloader.py


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