@@ -134,32 +134,32 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
134
134
if not self .fileOutput and ((self .outsz + blockSizeOnDisk ) > self .maxOutSz ):
135
135
self .outF .close ()
136
136
if self .setFileTime :
137
- os .utime (outFname , (int (time .time ()), highTS ))
137
+ os .utime (self . outFname , (int (time .time ()), self . highTS ))
138
138
self .outF = None
139
139
self .outFname = None
140
140
self .outFn = self .outFn + 1
141
141
self .outsz = 0
142
142
143
143
(blkDate , blkTS ) = get_blk_dt (blk_hdr )
144
144
if self .timestampSplit and (blkDate > self .lastDate ):
145
- print ("New month " + blkDate .strftime ("%Y-%m" ) + " @ " + hash_str )
146
- lastDate = blkDate
147
- if outF :
148
- outF .close ()
149
- if setFileTime :
150
- os .utime (outFname , (int (time .time ()), highTS ))
145
+ print ("New month " + blkDate .strftime ("%Y-%m" ) + " @ " + self . hash_str )
146
+ self . lastDate = blkDate
147
+ if self . outF :
148
+ self . outF .close ()
149
+ if self . setFileTime :
150
+ os .utime (self . outFname , (int (time .time ()), self . highTS ))
151
151
self .outF = None
152
152
self .outFname = None
153
153
self .outFn = self .outFn + 1
154
154
self .outsz = 0
155
155
156
156
if not self .outF :
157
157
if self .fileOutput :
158
- outFname = self .settings ['output_file' ]
158
+ self . outFname = self .settings ['output_file' ]
159
159
else :
160
- outFname = os .path .join (self .settings ['output' ], "blk%05d.dat" % self .outFn )
161
- print ("Output file " + outFname )
162
- self .outF = open (outFname , "wb" )
160
+ self . outFname = os .path .join (self .settings ['output' ], "blk%05d.dat" % self .outFn )
161
+ print ("Output file " + self . outFname )
162
+ self .outF = open (self . outFname , "wb" )
163
163
164
164
self .outF .write (inhdr )
165
165
self .outF .write (blk_hdr )
@@ -223,13 +223,16 @@ def run(self):
223
223
blk_hdr = self .inF .read (80 )
224
224
inExtent = BlockExtent (self .inFn , self .inF .tell (), inhdr , blk_hdr , inLen )
225
225
226
- hash_str = calc_hash_str (blk_hdr )
227
- if not hash_str in blkmap :
228
- print ("Skipping unknown block " + hash_str )
226
+ self .hash_str = calc_hash_str (blk_hdr )
227
+ if not self .hash_str in blkmap :
228
+ # Because blocks can be written to files out-of-order as of 0.10, the script
229
+ # may encounter blocks it doesn't know about. Treat as debug output.
230
+ if settings ['debug_output' ] == 'true' :
231
+ print ("Skipping unknown block " + self .hash_str )
229
232
self .inF .seek (inLen , os .SEEK_CUR )
230
233
continue
231
234
232
- blkHeight = self .blkmap [hash_str ]
235
+ blkHeight = self .blkmap [self . hash_str ]
233
236
self .blkCountIn += 1
234
237
235
238
if self .blkCountOut == blkHeight :
@@ -295,12 +298,15 @@ def run(self):
295
298
settings ['max_out_sz' ] = 1000 * 1000 * 1000
296
299
if 'out_of_order_cache_sz' not in settings :
297
300
settings ['out_of_order_cache_sz' ] = 100 * 1000 * 1000
301
+ if 'debug_output' not in settings :
302
+ settings ['debug_output' ] = 'false'
298
303
299
304
settings ['max_out_sz' ] = int (settings ['max_out_sz' ])
300
305
settings ['split_timestamp' ] = int (settings ['split_timestamp' ])
301
306
settings ['file_timestamp' ] = int (settings ['file_timestamp' ])
302
307
settings ['netmagic' ] = unhexlify (settings ['netmagic' ].encode ('utf-8' ))
303
308
settings ['out_of_order_cache_sz' ] = int (settings ['out_of_order_cache_sz' ])
309
+ settings ['debug_output' ] = settings ['debug_output' ].lower ()
304
310
305
311
if 'output_file' not in settings and 'output' not in settings :
306
312
print ("Missing output file / directory" )
0 commit comments