alt path for headers

This commit is contained in:
thomasv 2012-10-25 10:00:11 +02:00
parent b018e0ae53
commit b3b31fdc07

View file

@ -132,15 +132,8 @@ class WalletVerifier(threading.Thread):
header = self.header_from_string(raw_header) header = self.header_from_string(raw_header)
_hash = self.hash_header(header) _hash = self.hash_header(header)
assert previous_hash == header.get('prev_block_hash') assert previous_hash == header.get('prev_block_hash')
try: assert bits == header.get('bits')
assert bits == header.get('bits') assert eval('0x'+_hash) < target
except:
print index, hex(bits), hex(header.get('bits'))
try:
assert eval('0x'+_hash) < target
except:
print _hash, hex(target)
previous_header = header previous_header = header
previous_hash = _hash previous_hash = _hash
@ -202,20 +195,27 @@ class WalletVerifier(threading.Thread):
return hash_encode(h) return hash_encode(h)
def save_chunk(self, index, chunk): def path(self):
name = os.path.join( user_dir(), 'blockchain_headers') wdir = user_dir()
if os.path.exists(name): if not os.path.exists( wdir ):
f = open(name,'rw+') wdir = os.path.dirname(self.config.path)
else: return os.path.join( wdir, 'blockchain_headers')
f = open(name,'w+')
def save_chunk(self, index, chunk):
filename = self.path()
if os.path.exists(filename):
f = open(filename,'rw+')
else:
print "creating file", filename
f = open(filename,'w+')
f.seek(index*2016*80) f.seek(index*2016*80)
h = f.write(chunk) h = f.write(chunk)
f.close() f.close()
def read_header(self, block_height): def read_header(self, block_height):
name = os.path.join( user_dir(), 'blockchain_headers') name = self.path()
if os.path.exists(name): if os.path.exists(name):
f = open(name,'rb') f = open(name,'rb')
f.seek(block_height*80) f.seek(block_height*80)