1
0

initial testnet support (petrkr)

This commit is contained in:
ThomasV
2017-01-07 16:58:23 +01:00
parent 9138cf3cb8
commit d042d6e970
8 changed files with 82 additions and 71 deletions

View File

@@ -27,6 +27,7 @@
import os
import util
import bitcoin
from bitcoin import *
MAX_TARGET = 0x00000000FFFF0000000000000000000000000000000000000000000000000000
@@ -51,6 +52,7 @@ class Blockchain(util.PrintError):
def verify_header(self, header, prev_header, bits, target):
prev_hash = self.hash_header(prev_header)
assert prev_hash == header.get('prev_block_hash'), "prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash'))
if bitcoin.TESTNET: return
assert bits == header.get('bits'), "bits mismatch: %s vs %s" % (bits, header.get('bits'))
_hash = self.hash_header(header)
assert int('0x' + _hash, 16) <= target, "insufficient proof of work: %s vs target %s" % (int('0x' + _hash, 16), target)
@@ -109,6 +111,7 @@ class Blockchain(util.PrintError):
if os.path.exists(filename):
return
try:
if bitcoin.TESTNET: raise
import urllib, socket
socket.setdefaulttimeout(30)
self.print_error("downloading ", self.headers_url)