aboutsummaryrefslogtreecommitdiff
path: root/contrib/linearize
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/linearize')
-rw-r--r--contrib/linearize/README.md6
-rw-r--r--contrib/linearize/example-linearize.cfg10
-rwxr-xr-xcontrib/linearize/linearize-data.py28
-rwxr-xr-xcontrib/linearize/linearize-hashes.py4
4 files changed, 31 insertions, 17 deletions
diff --git a/contrib/linearize/README.md b/contrib/linearize/README.md
index 157586e4d4..06f278f3b3 100644
--- a/contrib/linearize/README.md
+++ b/contrib/linearize/README.md
@@ -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
@@ -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
@@ -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
diff --git a/contrib/linearize/example-linearize.cfg b/contrib/linearize/example-linearize.cfg
index e0fef13886..38da02e66c 100644
--- a/contrib/linearize/example-linearize.cfg
+++ b/contrib/linearize/example-linearize.cfg
@@ -4,13 +4,23 @@ rpcuser=someuser
rpcpassword=somepassword
host=127.0.0.1
port=8332
+#port=18332
# bootstrap.dat hashlist settings (linearize-hashes)
max_height=313000
# bootstrap.dat input/output settings (linearize-data)
+
+# mainnet
netmagic=f9beb4d9
+genesis=000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
input=/home/example/.bitcoin/blocks
+
+# testnet
+#netmagic=0b110907
+#genesis=000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943
+#input=/home/example/.bitcoin/testnet3/blocks
+
output_file=/home/example/Downloads/bootstrap.dat
hashlist=hashlist.txt
split_year=1
diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py
index 2dac3a614b..0f6fde2a6e 100755
--- a/contrib/linearize/linearize-data.py
+++ b/contrib/linearize/linearize-data.py
@@ -2,8 +2,8 @@
#
# linearize-data.py: Construct a linear, no-fork version of the chain.
#
-# Copyright (c) 2013-2014 The Bitcoin developers
-# Distributed under the MIT/X11 software license, see the accompanying
+# Copyright (c) 2013-2014 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
@@ -12,6 +12,7 @@ import json
import struct
import re
import os
+import os.path
import base64
import httplib
import sys
@@ -115,19 +116,20 @@ class BlockDataCopier:
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)
@@ -147,8 +149,8 @@ class BlockDataCopier:
if self.fileOutput:
outFname = self.settings['output_file']
else:
- outFname = "%s/blk%05d.dat" % (self.settings['output'], outFn)
- print("Output file" + outFname)
+ outFname = os.path.join(self.settings['output'], "blk%05d.dat" % self.outFn)
+ print("Output file " + outFname)
self.outF = open(outFname, "wb")
self.outF.write(inhdr)
@@ -165,7 +167,7 @@ class BlockDataCopier:
(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'''
@@ -189,7 +191,7 @@ class BlockDataCopier:
while self.blkCountOut < len(self.blkindex):
if not self.inF:
fname = self.inFileName(self.inFn)
- print("Input file" + fname)
+ print("Input file " + fname)
try:
self.inF = open(fname, "rb")
except IOError:
@@ -205,7 +207,7 @@ class BlockDataCopier:
inMagic = inhdr[:4]
if (inMagic != self.settings['netmagic']):
- print("Invalid magic:" + inMagic)
+ print("Invalid magic: " + inMagic.encode('hex'))
return
inLenLE = inhdr[4:]
su = struct.unpack("<I", inLenLE)
@@ -265,6 +267,8 @@ if __name__ == '__main__':
if 'netmagic' not in settings:
settings['netmagic'] = 'f9beb4d9'
+ if 'genesis' not in settings:
+ settings['genesis'] = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
if 'input' not in settings:
settings['input'] = 'input'
if 'hashlist' not in settings:
@@ -291,8 +295,8 @@ if __name__ == '__main__':
blkindex = get_block_hashes(settings)
blkmap = mkblockmap(blkindex)
- if not "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" in blkmap:
- print("not found")
+ if not settings['genesis'] in blkmap:
+ print("Genesis block not found in hashlist")
else:
BlockDataCopier(settings, blkindex, blkmap).run()
diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py
index dc7f654049..854cf1f9ee 100755
--- a/contrib/linearize/linearize-hashes.py
+++ b/contrib/linearize/linearize-hashes.py
@@ -2,8 +2,8 @@
#
# linearize-hashes.py: List blocks in a linear, no-fork version of the chain.
#
-# Copyright (c) 2013-2014 The Bitcoin developers
-# Distributed under the MIT/X11 software license, see the accompanying
+# Copyright (c) 2013-2014 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#