From 8f5a423344b277fbb63eb4295ce5928e16c6dc9d Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 24 Aug 2014 01:40:40 -0400 Subject: [PATCH] contrib/linearize: split block files based on year-month, not just year --- contrib/linearize/linearize-data.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py index 2d57d245f..3a4c9759f 100755 --- a/contrib/linearize/linearize-data.py +++ b/contrib/linearize/linearize-data.py @@ -58,10 +58,11 @@ def calc_hash_str(blk_hdr): hash_str = hash.encode('hex') return hash_str -def get_blk_year(blk_hdr): +def get_blk_dt(blk_hdr): members = struct.unpack(" lastYear: - print("New year " + str(blkYear) + " @ " + hash_str) - lastYear = blkYear + if timestampSplit: + blkDate = get_blk_dt(blk_hdr) + if blkDate > lastDate: + print("New month " + blkDate.strftime("%Y-%m") + " @ " + hash_str) + lastDate = blkDate if outF: outF.close() outF = None @@ -190,13 +191,13 @@ if __name__ == '__main__': settings['input'] = 'input' if 'hashlist' not in settings: settings['hashlist'] = 'hashlist.txt' - if 'split_year' not in settings: - settings['split_year'] = 0 + if 'split_timestamp' not in settings: + settings['split_timestamp'] = 0 if 'max_out_sz' not in settings: settings['max_out_sz'] = 1000L * 1000 * 1000 settings['max_out_sz'] = long(settings['max_out_sz']) - settings['split_year'] = int(settings['split_year']) + settings['split_timestamp'] = int(settings['split_timestamp']) settings['netmagic'] = settings['netmagic'].decode('hex') if 'output_file' not in settings and 'output' not in settings: