electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 3216c0467d2bb99ef4e6a2d94fe6eab791fa8b66
parent 1ecce5dffcf9d508db07a276d918cc0282acf8e0
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 26 Oct 2012 18:25:43 +0200

use print_error

Diffstat:
Mlib/interface.py | 9++++-----
Mlib/verifier.py | 17++++++++---------
2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/lib/interface.py b/lib/interface.py @@ -81,7 +81,7 @@ class Interface(threading.Thread): error = c.get('error') if error: - print "received error:", c + print_error("received error:", c) return if msg_id is not None: @@ -112,8 +112,8 @@ class Interface(threading.Thread): channel = k break else: - print "received unexpected notification", method, params - print self.subscriptions + print_error( "received unexpected notification", method, params) + print_error( self.subscriptions ) return response_queue = self.responses[channel] @@ -259,7 +259,6 @@ class Interface(threading.Thread): while self.is_connected: try: msg = self.s.recv(1024) except socket.timeout: - print "timeout" # ping the server with server.version, as a real ping does not exist yet self.send([('server.version', [ELECTRUM_VERSION])]) continue @@ -301,7 +300,7 @@ class Interface(threading.Thread): out = out[sent:] except: # this happens when we get disconnected - print "Not connected, cannot send" + print_error( "Not connected, cannot send" ) return None return ids diff --git a/lib/verifier.py b/lib/verifier.py @@ -18,7 +18,7 @@ import threading, time, Queue, os, sys -from util import user_dir +from util import user_dir, print_error from bitcoin import * @@ -77,7 +77,7 @@ class WalletVerifier(threading.Thread): break else: all_chunks = True - print "all chunks" + print_error("downloaded all chunks") # request missing tx merkle for tx in self.transactions: @@ -98,7 +98,7 @@ class WalletVerifier(threading.Thread): # request previous header i = header.get('block_height') - 1 if i not in requested_headers: - print "requesting header", i + print_error("requesting header %d"%i) self.interface.send([ ('blockchain.block.get_header',[i])], 'verifier') requested_headers.append(i) # no point continuing @@ -154,7 +154,7 @@ class WalletVerifier(threading.Thread): if header: assert header.get('merkle_root') == self.merkle_roots[tx_hash] self.verified_tx[tx_hash] = tx_height - print "verified", tx_hash + print_error("verified %s"%tx_hash) self.config.set_key('verified_tx', self.verified_tx, True) @@ -162,7 +162,7 @@ class WalletVerifier(threading.Thread): data = hexdata.decode('hex') height = index*2016 num = len(data)/80 - print "validating headers", height, num + print_error("validating headers %d"%height) if index == 0: previous_hash = ("0"*64) @@ -196,7 +196,7 @@ class WalletVerifier(threading.Thread): prev_header = self.read_header(height -1) if not prev_header: - print "no previous header", height + print_error("no previous header: %s"%height) return False #prev_hash = prev_header.get('block_height') @@ -208,12 +208,12 @@ class WalletVerifier(threading.Thread): assert bits == header.get('bits') assert eval('0x'+_hash) < target except: - print "verify header failed", header + print_error("verify header failed"+ repr(header)) # this can be caused by a reorg. returning False will request the previous header. return False self.save_header(header) - print "verify header: ok", height + print_error("verify header: ok %d"%height) return True @@ -337,6 +337,5 @@ class WalletVerifier(threading.Thread): i += 1 new_bits = c + MM * i - # print "%3d"%index, "%8x"%bits, "%64X"%new_target, hex(c)[2:].upper(), hex(new_bits) return new_bits, new_target