本文整理汇总了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()
示例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
示例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
示例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
示例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
示例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()