Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions contrib/linearize/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Linearize
Construct a linear, no-fork, best version of the blockchain.

## Step 0: Install dash_hash

https://github.com/UdjinM6/dash_hash

## Step 1: Download hash list

$ ./linearize-hashes.py linearize.cfg > hashlist.txt
Expand All @@ -20,13 +24,12 @@ Required configuration file settings:
* "input": bitcoind blocks/ directory containing blkNNNNN.dat
* "hashlist": text file containing list of block hashes, linearized-hashes.py
output.
* "output_file": bootstrap.dat
or
* "output": output directory for linearized blocks/blkNNNNN.dat output
* "output_file" for bootstrap.dat or "output" for output directory for linearized blocks/blkNNNNN.dat output

Optional config file setting for linearize-data:
* "netmagic": network magic number
* "max_out_sz": maximum output file size (default 1000*1000*1000)
* "netmagic": network magic number (default is 'cee2caff', testnet)
* "genesis": genesis block hash (default is '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c', testnet)
* "max_out_sz": maximum output file size (default 100 \* 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
20 changes: 20 additions & 0 deletions contrib/linearize/example-linearize-testnet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# bitcoind RPC settings (linearize-hashes)
rpcuser=someuser
rpcpassword=somepassword
host=127.0.0.1
port=19998

# bootstrap.dat hashlist settings (linearize-hashes)
max_height=3130000

# bootstrap.dat input/output settings (linearize-data)
netmagic=cee2caff
input=/home/example/.dash/testnet3/blocks
output_file=/home/example/Downloads/bootstrap.dat
hashlist=hashlist.txt
split_year=1
genesis=00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c

# Maxmimum size in bytes of out-of-order blocks cache in memory
out_of_order_cache_sz = 10000000
9 changes: 5 additions & 4 deletions contrib/linearize/example-linearize.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ host=127.0.0.1
port=9998

# bootstrap.dat hashlist settings (linearize-hashes)
max_height=313000
max_height=3130000

# bootstrap.dat input/output settings (linearize-data)
netmagic=f9beb4d9
input=/home/example/.bitcoin/blocks
netmagic=bf0c6bbd
input=/home/example/.dash/blocks
output_file=/home/example/Downloads/bootstrap.dat
hashlist=hashlist.txt
split_year=1
genesis=00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6

# Maxmimum size in bytes of out-of-order blocks cache in memory
out_of_order_cache_sz = 100000000
out_of_order_cache_sz = 10000000
26 changes: 15 additions & 11 deletions contrib/linearize/linearize-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import httplib
import sys
import hashlib
import dash_hash
import datetime
import time
from collections import namedtuple
Expand Down Expand Up @@ -44,15 +45,17 @@ def wordreverse(in_buf):
return ''.join(out_words)

def calc_hdr_hash(blk_hdr):
hash1 = hashlib.sha256()
hash1.update(blk_hdr)
hash1_o = hash1.digest()
#hash1 = hashlib.sha256()
#hash1.update(blk_hdr)
#hash1_o = hash1.digest()

hash2 = hashlib.sha256()
hash2.update(hash1_o)
hash2_o = hash2.digest()
#hash2 = hashlib.sha256()
#hash2.update(hash1_o)
#hash2_o = hash2.digest()

return hash2_o
#return hash2_o
pow_hash = dash_hash.getPoWHash(blk_hdr)
return pow_hash

def calc_hash_str(blk_hdr):
hash = calc_hdr_hash(blk_hdr)
Expand Down Expand Up @@ -264,7 +267,9 @@ def run(self):
f.close()

if 'netmagic' not in settings:
settings['netmagic'] = 'f9beb4d9'
settings['netmagic'] = 'cee2caff'
if 'genesis' not in settings:
settings['genesis'] = '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'
if 'input' not in settings:
settings['input'] = 'input'
if 'hashlist' not in settings:
Expand All @@ -291,9 +296,8 @@ def run(self):
blkindex = get_block_hashes(settings)
blkmap = mkblockmap(blkindex)

if not "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" in blkmap:
print("not found")
if not settings['genesis'] in blkmap:
print("genesis not found")
else:
BlockDataCopier(settings, blkindex, blkmap).run()