Skip to content

Commit dcc495e

Browse files
committed
Merge pull request #6372
e3c4297 Update Linearize tool to support Windows paths (Paul Georgiou)
2 parents fe3fe54 + e3c4297 commit dcc495e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

contrib/linearize/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Construct a linear, no-fork, best version of the blockchain.
33

44
## Step 1: Download hash list
55

6-
$ ./linearize-hashes.py linearize.cfg > hashlist.txt
6+
$ ./linearize-hashes.py linearize.cfg > hashlist.txt
77

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

1515
## Step 2: Copy local block data
1616

17-
$ ./linearize-data.py linearize.cfg
17+
$ ./linearize-data.py linearize.cfg
1818

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

2727
Optional config file setting for linearize-data:
2828
* "netmagic": network magic number
29-
* "max_out_sz": maximum output file size (default 1000*1000*1000)
29+
* "max_out_sz": maximum output file size (default `1000*1000*1000`)
3030
* "split_timestamp": Split files when a new month is first seen, in addition to
3131
reaching a maximum file size.
3232
* "file_timestamp": Set each file's last-modified time to that of the

contrib/linearize/linearize-data.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import struct
1313
import re
1414
import os
15+
import os.path
1516
import base64
1617
import httplib
1718
import sys
@@ -115,19 +116,20 @@ def __init__(self, settings, blkindex, blkmap):
115116
self.setFileTime = True
116117
if settings['split_timestamp'] != 0:
117118
self.timestampSplit = True
118-
# Extents and cache for out-of-order blocks
119+
# Extents and cache for out-of-order blocks
119120
self.blockExtents = {}
120121
self.outOfOrderData = {}
121122
self.outOfOrderSize = 0 # running total size for items in outOfOrderData
122123

123124
def writeBlock(self, inhdr, blk_hdr, rawblock):
124-
if not self.fileOutput and ((self.outsz + self.inLen) > self.maxOutSz):
125+
blockSizeOnDisk = len(inhdr) + len(blk_hdr) + len(rawblock)
126+
if not self.fileOutput and ((self.outsz + blockSizeOnDisk) > self.maxOutSz):
125127
self.outF.close()
126128
if self.setFileTime:
127129
os.utime(outFname, (int(time.time()), highTS))
128130
self.outF = None
129131
self.outFname = None
130-
self.outFn = outFn + 1
132+
self.outFn = self.outFn + 1
131133
self.outsz = 0
132134

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

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

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

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

0 commit comments

Comments
 (0)