do not bundle blockchain headers with packages
authorthomasv <thomasv@gitorious>
Mon, 17 Dec 2012 10:18:49 +0000 (11:18 +0100)
committerthomasv <thomasv@gitorious>
Mon, 17 Dec 2012 10:18:49 +0000 (11:18 +0100)
lib/verifier.py
make_packages
setup.py

index 1801edc..836fa6b 100644 (file)
@@ -43,9 +43,8 @@ class WalletVerifier(threading.Thread):
         self.pending_headers = [] # headers that have not been verified
         self.height = 0
         self.local_height = 0
-        self.init_headers_file()
-        self.set_local_height()
         self.running = False
+        self.headers_url = 'http://images.ecdsa.org/blockchain_headers'
 
     def get_confirmations(self, tx):
         """ return the number of confirmations of a monitored transaction. """
@@ -81,6 +80,10 @@ class WalletVerifier(threading.Thread):
         with self.lock: return self.running
 
     def run(self):
+
+        self.init_headers_file()
+        self.set_local_height()
+
         with self.lock:
             self.running = True
         requested_merkle = []
@@ -293,13 +296,17 @@ class WalletVerifier(threading.Thread):
         filename = self.path()
         if os.path.exists(filename):
             return
-        src = os.path.join(appdata_dir(), 'blockchain_headers')
-        if os.path.exists(src):
-            # copy it from appdata dir
-            print_error( "copying headers to", filename )
-            shutil.copy(src, filename)
-        else:
-            print_error( "creating headers file", filename )
+        import urllib2
+        try:
+            print_error("downloading ", self.headers_url )
+            f = urllib2.urlopen(self.headers_url)
+            s = f.read()
+            f.close()
+            f = open(filename,'wb+')
+            f.write(s)
+            f.close()
+        except:
+            print_error( "download failed. creating file", filename )
             open(filename,'wb+').close()
 
     def save_chunk(self, index, chunk):
index 8dc89db..67cb5f3 100755 (executable)
@@ -9,10 +9,6 @@ if __name__ == '__main__':
         print "aes and ecdsa are missing. copy them locally before."
         sys.exit()
 
-    if not os.path.exists('data/blockchain_headers'):
-        print "header file is missing"
-        sys.exit()
-
     os.system("python mki18n.py")
     os.system("pyrcc4 icons.qrc -o lib/icons_rc.py")
     os.system("python setup.py sdist --format=zip,gztar")
@@ -28,14 +24,13 @@ if __name__ == '__main__':
     shutil.copytree("ecdsa",'dist/e4a-%s/ecdsa'%version)
     shutil.copytree("aes",'dist/e4a-%s/aes'%version)
     shutil.copytree("lib",'dist/e4a-%s/electrum'%version)
-    shutil.copyfile("data/blockchain_headers",'dist/e4a-%s/blockchain_headers'%version)
 
-    os.chdir("dist" )    
+    os.chdir("dist")
     # create the zip file
     os.system( "zip -r e4a-%s.zip e4a-%s"%(version, version) )
     # copy to a filename without extension
     os.system( "cp e4a-%s.zip e4a"%version )
-    os.chdir(".." )
+    os.chdir("..")
 
     md5_tgz = hashlib.md5(file('dist/'+_tgz, 'r').read()).digest().encode('hex')
     md5_zip = hashlib.md5(file('dist/'+_zip, 'r').read()).digest().encode('hex')
index 8f653a8..d1fb027 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -37,8 +37,6 @@ data_files += [
     ])
 ]
 
-if os.path.exists("data/blockchain_headers"):
-    data_files.append( (util.appdata_dir(), ["data/blockchain_headers"]) )
 
 setup(name = "Electrum",
     version = version.ELECTRUM_VERSION,