Skip to content

Commit

Permalink
add: bootstrap height at 4421701
Browse files Browse the repository at this point in the history
sugarchain-project/sugarchain#143

* scripts: In linearize, search for next position of magic bytes rather than fail
bitcoin/bitcoin#16802

* add: bootstrap height at 4421701
  • Loading branch information
decryp2kanon committed May 18, 2020
1 parent ddc243d commit 6ab41d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ Construct a linear, no-fork, best version of the Bitcoin blockchain. The scripts
run using Python 3 but are compatible with Python 2.

## Warning
Do not use `-txindex=1` in this script.
Do not use `-txindex=1` in this script.

## Stop 0: Fix `max_height` in `linearize.cfg`
## Step 1:
Fix `max_height` in `linearize.cfg`

## Step 1: Download hash list
## Step 1.1: Download hash list

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

Expand All @@ -28,19 +29,20 @@ the same data no matter which byte format is chosen.
The `linearize-hashes` script requires a connection, local or remote, to a
JSON-RPC server. Running `bitcoind` or `bitcoin-qt -server` will be sufficient.

## Step 1.1: Change absolute location in `linearize.cfg`
## Step 1.2:
Change absolute location in `linearize.cfg`

input=/home/{USERNAME}/.sugarchain/blocks
output_file=/home/{USERNAME}/Desktop/bootstrap.dat

## Step 1.2: Check outputs
## Step 1.3: Check outputs

$ head -1 hashlist.txt # genesis
7d5eaec2dbb75f99feadfa524c78b7cabc1d8c8204f79d4f3a83381b811b0adc
$ wc -l hashlist.txt # 2601001+1 (add genesis)
2601002 hashlist.txt
$ tail -n 1 hashlist.txt # height 2601001 # getblockhash 2601001
56e8f536feb26f749ed9198f56f397da08f018de9518674b2ac12a41061612cb
$ wc -l hashlist.txt # 4421701+1 (add genesis)
4421702 hashlist.txt
$ tail -n 1 hashlist.txt # height 4421701 # getblockhash 4421701
9a9c7db86b1a67a399d50f7f45b1d4bbb9179bcf0be08331239a1b9881ebcea9

## Step 2: Copy local block data

Expand Down
7 changes: 5 additions & 2 deletions linearize-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ def run(self):

inMagic = inhdr[:4]
if (inMagic != self.settings['netmagic']):
print("Invalid magic: " + hexlify(inMagic).decode('utf-8'))
return
# Seek backwards 7 bytes (skipping the first byte in the previous search)
# and continue searching from the new position if the magic bytes are not
# found.
self.inF.seek(-7, os.SEEK_CUR)
continue
inLenLE = inhdr[4:]
su = struct.unpack("<I", inLenLE)
inLen = su[0] - 80 # length without header
Expand Down
6 changes: 3 additions & 3 deletions linearize.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ port=34229
#port=45339

# bootstrap.dat hashlist settings (linearize-hashes)
# at this moment, the height is approx. 2825602 (2020-02-03)
# 510*(510*10)+1
max_height=2601001
# at this moment, the height is approx. 4638846 (2020-05-18)
# (510*510*17)+1=4421701
max_height=4421701

# bootstrap.dat input/output settings (linearize-data)

Expand Down

0 comments on commit 6ab41d0

Please sign in to comment.