1
0

bitcoin.NetworkConstants: easier changing between testnet and mainnet

This commit is contained in:
SomberNight
2017-11-09 17:47:57 +01:00
parent b4bea48b22
commit 0db5ea67a0
9 changed files with 55 additions and 57 deletions

View File

@@ -148,7 +148,7 @@ class Blockchain(util.PrintError):
_hash = hash_header(header)
if prev_hash != header.get('prev_block_hash'):
raise BaseException("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
if bitcoin.TESTNET:
if bitcoin.NetworkConstants.TESTNET:
return
if bits != header.get('bits'):
raise BaseException("bits mismatch: %s vs %s" % (bits, header.get('bits')))
@@ -265,7 +265,7 @@ class Blockchain(util.PrintError):
return sum([self.BIP9(h-i, 2) for i in range(N)])*10000/N/100.
def get_target(self, index):
if bitcoin.TESTNET:
if bitcoin.NetworkConstants.TESTNET:
return 0, 0
if index == 0:
return 0x1d00ffff, MAX_TARGET
@@ -302,7 +302,7 @@ class Blockchain(util.PrintError):
if check_height and self.height() != height - 1:
return False
if height == 0:
return hash_header(header) == bitcoin.GENESIS
return hash_header(header) == bitcoin.NetworkConstants.GENESIS
previous_header = self.read_header(height -1)
if not previous_header:
return False