Skip to content

Commit

Permalink
Merge pull request #2 from starrygit/bcd
Browse files Browse the repository at this point in the history
bug fix:  Synchronize really block headers, not fake headers
  • Loading branch information
Starry9 committed Jan 18, 2018
2 parents 8531355 + dd3379e commit a9ffa67
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 991 deletions.
1 change: 1 addition & 0 deletions lib/bitcoin.py
Expand Up @@ -86,6 +86,7 @@ def set_mainnet(cls):
# Bitcoin Diamond fork block specification
cls.BITCOIN_DIAMOND_FORK_BLOCK_HEIGHT = 495867
cls.BITCOIN_DIAMOND_FORK_BLOCK_HASH = '458535405446053c9db6a16ec7e5b022429fedde605ce81bb24c6cfe6f43fc89'
cls.BITCOIN_DIAMOND_CHECKPOINT_INDEX = 495867 // 2016

@classmethod
def set_testnet(cls):
Expand Down
5 changes: 3 additions & 2 deletions lib/blockchain.py
Expand Up @@ -170,7 +170,8 @@ def verify_header(self, header, prev_hash, target):
def verify_chunk(self, index, data):
num = len(data) // 80
prev_hash = self.get_hash(index * 2016 - 1)
target = self.get_target(index-1)
# target = self.get_target(index-1)
target = self.get_target(index * 2016)
for i in range(num):
raw_header = data[i*80:(i+1) * 80]
header = deserialize_header(raw_header, index*2016 + i)
Expand Down Expand Up @@ -286,7 +287,7 @@ def get_target(self, height):
else:
return self.get_bcd_target(height)
if index == -1:
return 0x1d00ffff, MAX_TARGET
return MAX_TARGET
if index < len(self.checkpoints):
h, t = self.checkpoints[index]
return t
Expand Down

0 comments on commit a9ffa67

Please sign in to comment.