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


Python BCDataStream.close_file方法代码示例

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


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

示例1: _dump_tx

# 需要导入模块: import BCDataStream [as 别名]
# 或者: from BCDataStream import close_file [as 别名]
def _dump_tx(datadir, tx_hash, tx_pos):
  blockfile = open(os.path.join(datadir, "blk%04d.dat"%(tx_pos[0],)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, tx_pos[2])
  d = parse_Transaction(ds)
  print deserialize_Transaction(d)
  ds.close_file()
  blockfile.close()
开发者ID:CsD-kop,项目名称:bitcointools,代码行数:10,代码来源:transaction.py

示例2: _dump_tx

# 需要导入模块: import BCDataStream [as 别名]
# 或者: from BCDataStream import close_file [as 别名]
def _dump_tx(datadir, tx_hash, tx_pos):
  BLOCK_HEADER_SIZE = 80
  blockfile = open(os.path.join(datadir, "blocks","blk%05d.dat"%(tx_pos[0],)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, tx_pos[1]+BLOCK_HEADER_SIZE+tx_pos[2])
  tx = parse_Transaction(ds)
  tx['hash'] = tx_hash[::-1]
  ds.close_file()
  blockfile.close()
  return tx
开发者ID:haobtc,项目名称:openblockchain,代码行数:12,代码来源:test.py

示例3: _dump_block

# 需要导入模块: import BCDataStream [as 别名]
# 或者: from BCDataStream import close_file [as 别名]
def _dump_block(datadir, nFile, nBlockPos, blkhash):
  blockfile = open(os.path.join(datadir,"blocks","blk%05d.dat"%(nFile,)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, nBlockPos)
  block_start = ds.read_cursor
  block = parse_Block(ds)
  block_end = ds.read_cursor
  block['blk_size'] = (block_end - block_start)
  ds.close_file()
  blockfile.close()
  return block
开发者ID:haobtc,项目名称:openblockchain,代码行数:13,代码来源:test.py

示例4: _dump_block

# 需要导入模块: import BCDataStream [as 别名]
# 或者: from BCDataStream import close_file [as 别名]
def _dump_block(datadir, nFile, nBlockPos, hash256, hashNext, do_print=True):
    blockfile = open(os.path.join(datadir, "blk%04d.dat" % (nFile,)), "rb")
    ds = BCDataStream()
    ds.map_file(blockfile, nBlockPos)
    d = parse_Block(ds)
    block_string = deserialize_Block(d)
    ds.close_file()
    blockfile.close()
    if do_print:
        print "BLOCK " + long_hex(hash256[::-1])
        print "Next block: " + long_hex(hashNext[::-1])
        print block_string
    return block_string
开发者ID:tuxsoul,项目名称:bitcoin-tools,代码行数:15,代码来源:block.py

示例5: _dump_block

# 需要导入模块: import BCDataStream [as 别名]
# 或者: from BCDataStream import close_file [as 别名]
def _dump_block(datadir, nFile, nBlockPos, hash256, hashNext, do_print=True, print_raw_tx=False, print_json=False):
  blockfile = open(os.path.join(datadir, "blk%04d.dat"%(nFile,)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, nBlockPos)
  d = parse_Block(ds)
  block_string = deserialize_Block(d, print_raw_tx)
  ds.close_file()
  blockfile.close()
  if do_print:
    print "BLOCK "+long_hex(hash256[::-1])
    print "Next block: "+long_hex(hashNext[::-1])
    print block_string
  elif print_json:
    import json
    print json.dumps({
                        'version': d['version'],
                        'previousblockhash': d['hashPrev'][::-1].encode('hex'),
                        'transactions' : [ tx_hex['__data__'].encode('hex') for tx_hex in d['transactions'] ],
                        'time' : d['nTime'],
                        'bits' : hex(d['nBits']).lstrip("0x"),
                        'nonce' : d['nNonce']
                      })

  return block_string
开发者ID:3pence,项目名称:bitcointools,代码行数:26,代码来源:block.py

示例6: dumpblock

# 需要导入模块: import BCDataStream [as 别名]
# 或者: from BCDataStream import close_file [as 别名]
 def dumpblock(self,block_position, block_time, opened_file):
     ds = BCDataStream()
     ds.map_file(opened_file, block_position)
     d = parse_Block(ds)
     deserialize_Block(d, block_time, self.addresses)
     ds.close_file()
开发者ID:BlastarIndia,项目名称:BitXBay,代码行数:8,代码来源:helper.py


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