URI: 
       tfix bug with hex_to_int; remove unused function - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit df76aac2db685dc569af68b44717bed4901b78bd
   DIR parent 69639f901c42df6e4d30f909adc028880d1a23ac
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Tue, 12 Nov 2013 10:14:29 +0100
       
       fix bug with hex_to_int; remove unused function
       
       Diffstat:
         M lib/blockchain.py                   |      39 ++++---------------------------
         M lib/util.py                         |       4 ----
       
       2 files changed, 5 insertions(+), 38 deletions(-)
       ---
   DIR diff --git a/lib/blockchain.py b/lib/blockchain.py
       t@@ -18,7 +18,7 @@
        
        
        import threading, time, Queue, os, sys, shutil
       -from util import user_dir, appdata_dir, print_error, hex_to_int
       +from util import user_dir, appdata_dir, print_error
        from bitcoin import *
        
        
       t@@ -118,7 +118,7 @@ class Blockchain(threading.Thread):
                    try:
                        assert prev_hash == header.get('prev_block_hash')
                        assert bits == header.get('bits')
       -                assert hex_to_int(_hash) < target
       +                assert int('0x'+_hash,16) < target
                    except Exception:
                        return False
        
       t@@ -149,7 +149,7 @@ class Blockchain(threading.Thread):
                    _hash = self.hash_header(header)
                    assert previous_hash == header.get('prev_block_hash')
                    assert bits == header.get('bits')
       -            assert hex_to_int(_hash) < target
       +            assert int('0x'+_hash,16) < target
        
                    previous_header = header
                    previous_hash = _hash 
       t@@ -157,36 +157,6 @@ class Blockchain(threading.Thread):
                self.save_chunk(index, data)
                print_error("validated chunk %d"%height)
        
       -
       -    def verify_header(self, header):
       -        # add header to the blockchain file
       -        # if there is a reorg, push it in a stack
       -
       -        height = header.get('block_height')
       -
       -        prev_header = self.read_header(height -1)
       -        if not prev_header:
       -            # return False to request previous header
       -            return False
       -
       -        prev_hash = self.hash_header(prev_header)
       -        bits, target = self.get_target(height/2016)
       -        _hash = self.hash_header(header)
       -        try:
       -            assert prev_hash == header.get('prev_block_hash')
       -            assert bits == header.get('bits')
       -            assert hex_to_int(_hash) < target
       -        except Exception:
       -            # this can be caused by a reorg.
       -            print_error("verify header failed"+ repr(header))
       -            verifier.undo_verifications()
       -
       -            # return False to request previous header.
       -            return False
       -
       -        self.save_header(header)
       -        print_error("verify header:", _hash, height)
       -        return True
                
        
            def header_to_string(self, res):
       t@@ -200,6 +170,7 @@ class Blockchain(threading.Thread):
        
        
            def header_from_string(self, s):
       +        hex_to_int = lambda s: int('0x' + s[::-1].encode('hex'), 16)
                h = {}
                h['version'] = hex_to_int(s[0:4])
                h['prev_block_hash'] = hash_encode(s[4:36])
       t@@ -305,7 +276,7 @@ class Blockchain(threading.Thread):
                    c = c[2:]
                    i -= 1
        
       -        c = hex_to_int(c[0:6])
       +        c = int('0x'+c[0:6],16)
                if c > 0x800000: 
                    c /= 256
                    i += 1
   DIR diff --git a/lib/util.py b/lib/util.py
       t@@ -5,10 +5,6 @@ from datetime import datetime
        is_verbose = True
        
        
       -def hex_to_int(s):
       -    return int('0x' + s[::-1].encode('hex'), 16)
       -
       -
        class MyEncoder(json.JSONEncoder):
            def default(self, obj):
                from transaction import Transaction