Skip to content

Commit

Permalink
Merge pull request #6372
Browse files Browse the repository at this point in the history
e3c4297 Update Linearize tool to support Windows paths (Paul Georgiou)
  • Loading branch information
laanwj committed Jul 17, 2015
2 parents fe3fe54 + e3c4297 commit dcc495e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions contrib/linearize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Construct a linear, no-fork, best version of the blockchain.

## Step 1: Download hash list

$ ./linearize-hashes.py linearize.cfg > hashlist.txt
$ ./linearize-hashes.py linearize.cfg > hashlist.txt

Required configuration file settings for linearize-hashes:
* RPC: rpcuser, rpcpassword
Expand All @@ -14,7 +14,7 @@ Optional config file setting for linearize-hashes:

## Step 2: Copy local block data

$ ./linearize-data.py linearize.cfg
$ ./linearize-data.py linearize.cfg

Required configuration file settings:
* "input": bitcoind blocks/ directory containing blkNNNNN.dat
Expand All @@ -26,7 +26,7 @@ output.

Optional config file setting for linearize-data:
* "netmagic": network magic number
* "max_out_sz": maximum output file size (default 1000*1000*1000)
* "max_out_sz": maximum output file size (default `1000*1000*1000`)
* "split_timestamp": Split files when a new month is first seen, in addition to
reaching a maximum file size.
* "file_timestamp": Set each file's last-modified time to that of the
Expand Down
12 changes: 7 additions & 5 deletions contrib/linearize/linearize-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import struct
import re
import os
import os.path
import base64
import httplib
import sys
Expand Down Expand Up @@ -115,19 +116,20 @@ def __init__(self, settings, blkindex, blkmap):
self.setFileTime = True
if settings['split_timestamp'] != 0:
self.timestampSplit = True
# Extents and cache for out-of-order blocks
# Extents and cache for out-of-order blocks
self.blockExtents = {}
self.outOfOrderData = {}
self.outOfOrderSize = 0 # running total size for items in outOfOrderData

def writeBlock(self, inhdr, blk_hdr, rawblock):
if not self.fileOutput and ((self.outsz + self.inLen) > self.maxOutSz):
blockSizeOnDisk = len(inhdr) + len(blk_hdr) + len(rawblock)
if not self.fileOutput and ((self.outsz + blockSizeOnDisk) > self.maxOutSz):
self.outF.close()
if self.setFileTime:
os.utime(outFname, (int(time.time()), highTS))
self.outF = None
self.outFname = None
self.outFn = outFn + 1
self.outFn = self.outFn + 1
self.outsz = 0

(blkDate, blkTS) = get_blk_dt(blk_hdr)
Expand All @@ -147,7 +149,7 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
if self.fileOutput:
outFname = self.settings['output_file']
else:
outFname = "%s/blk%05d.dat" % (self.settings['output'], outFn)
outFname = os.path.join(self.settings['output'], "blk%05d.dat" % self.outFn)
print("Output file " + outFname)
self.outF = open(outFname, "wb")

Expand All @@ -165,7 +167,7 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
(self.blkCountIn, self.blkCountOut, len(self.blkindex), 100.0 * self.blkCountOut / len(self.blkindex)))

def inFileName(self, fn):
return "%s/blk%05d.dat" % (self.settings['input'], fn)
return os.path.join(self.settings['input'], "blk%05d.dat" % fn)

def fetchBlock(self, extent):
'''Fetch block contents from disk given extents'''
Expand Down

0 comments on commit dcc495e

Please sign in to comment.