4
from armoryengine import *
6
TheBDM.setBlocking(True)
7
TheBDM.setOnlineMode(True)
9
if not os.path.exists('testmultiblock'):
10
os.mkdir('testmultiblock')
13
fout.append([0, 101, 'testmultiblock/blk00000.dat'])
14
fout.append([0, 102, 'testmultiblock/blk00000_test1.dat']) # Add 1 block
15
fout.append([0, 105, 'testmultiblock/blk00000_test2.dat']) # Add 3 blocks
16
fout.append([106, 106, 'testmultiblock/blk00001_test3.dat']) # Just block split
17
fout.append([107, 109, 'testmultiblock/blk00002_test4.dat']) # Another block split 3 blks
18
fout.append([107, 110, 'testmultiblock/blk00002_test5.dat']) # Add block
19
fout.append([110, 113, 'testmultiblock/blk00003_test5.dat']) # and split
22
for start,end,theFile in fout:
23
if os.path.exists(theFile):
26
lastLocation = [0]*len(fout)
27
openfiles = [[trip[0], trip[1], open(trip[2],'wb')] for trip in fout]
29
# Assume we are only reading into blk000000.dat, no split
31
head = TheBDM.getHeaderByHeight(h)
32
blk = head.serializeWholeBlock(MAGIC_BYTES, True)
33
for i,trip in enumerate(openfiles):
34
start,end,theFile = trip
35
if (start <= h <= end):
37
lastLocation[i] += len(blk)
40
for start,end,opnfil in openfiles:
44
for i,trip in enumerate(fout):
45
start,end,theFile = trip
46
sz = os.path.getsize(theFile)
47
f = open(theFile,'ab')
49
f.write('\x00'*(22000-sz))
51
f.write('\x00'*(1000-sz))
54
print 'Blocks written out:'
55
for start,end,fn in fout:
57
print '\t%d in file: %s' % (end,fn)
59
print '\t%d-%d in file: %s' % (start,end,fn)