Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
252else: # If out-of-order, skip over block data for now253self.blockExtents[blkHeight] = inExtent254if self.outOfOrderSize < self.settings['out_of_order_cache_sz']:255# If there is space in the cache, read the data256# Reading the data in file sequence instead of seeking and fetching it later is preferred,257# but we don't want to fill up memory258self.outOfOrderData[blkHeight] = self.read_xored(self.inF, inLen)259self.outOfOrderSize += inLen260else: # If no space in cache, seek forward261self.inF.seek(inLen, os.SEEK_CUR)263print("Done (%i blocks written)" % (self.blkCountOut))265if __name__ == '__main__':266if len(sys.argv) != 2:267print("Usage: linearize-data.py CONFIG-FILE")268sys.exit(1)270with open(sys.argv[1]) as f:271for line in f:272# skip comment lines273m = re.search(r'^\s*#', line)274if m:275continue277# parse key=value lines278m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)279if m is None:280continue281settings[m.group(1)] = m.group(2)283# Force hash byte format setting to be lowercase to make comparisons easier.284# Also place upfront in case any settings need to know about it.285if 'rev_hash_bytes' not in settings:286settings['rev_hash_bytes'] = 'false'287settings['rev_hash_bytes'] = settings['rev_hash_bytes'].lower()289if 'netmagic' not in settings:290settings['netmagic'] = 'f9beb4d9'291if 'genesis' not in settings:292settings['genesis'] = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'293if 'input' not in settings:294settings['input'] = 'input'295if 'hashlist' not in settings:296settings['hashlist'] = 'hashlist.txt'297if 'file_timestamp' not in settings:298settings['file_timestamp'] = 0299if 'split_timestamp' not in settings:300settings['split_timestamp'] = 0301if 'max_out_sz' not in settings:302settings['max_out_sz'] = 1000 * 1000 * 1000303if 'out_of_order_cache_sz' not in settings:304settings['out_of_order_cache_sz'] = 100 * 1000 * 1000305if 'debug_output' not in settings:306settings['debug_output'] = 'false'308settings['max_out_sz'] = int(settings['max_out_sz'])309settings['split_timestamp'] = int(settings['split_timestamp'])310settings['file_timestamp'] = int(settings['file_timestamp'])311settings['netmagic'] = bytes.fromhex(settings['netmagic'])312settings['out_of_order_cache_sz'] = int(settings['out_of_order_cache_sz'])313settings['debug_output'] = settings['debug_output'].lower()315if 'output_file' not in settings and 'output' not in settings:316print("Missing output file / directory")317sys.exit(1)319blkindex = get_block_hashes(settings)320blkmap = mkblockmap(blkindex)322# Block hash map won't be byte-reversed. Neither should the genesis hash.323if settings['genesis'] not in blkmap:324print("Genesis block not found in hashlist")325else:326BlockDataCopier(settings, blkindex, blkmap).run()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.