1
0

rename spv class, use own print_error

This commit is contained in:
ThomasV
2015-03-14 09:20:27 +01:00
parent 5918bac5cb
commit 5b8588ee90
3 changed files with 8 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ from bitcoin import *
class TxVerifier(util.DaemonThread):
class SPV(util.DaemonThread):
""" Simple Payment Verification """
def __init__(self, network, storage):
@@ -95,7 +95,7 @@ class TxVerifier(util.DaemonThread):
continue
if self.merkle_roots.get(tx_hash) is None and tx_hash not in requested_merkle:
if self.network.send([ ('blockchain.transaction.get_merkle',[tx_hash, tx_height]) ], self.queue.put):
print_error('requesting merkle', tx_hash)
self.print_error('requesting merkle', tx_hash)
requested_merkle.append(tx_hash)
try:
r = self.queue.get(timeout=0.1)
@@ -105,7 +105,7 @@ class TxVerifier(util.DaemonThread):
continue
if r.get('error'):
print_error('Verifier received an error:', r)
self.print_error('Verifier received an error:', r)
continue
# 3. handle response
@@ -127,7 +127,7 @@ class TxVerifier(util.DaemonThread):
header = self.network.get_header(tx_height)
if not header: return
if header.get('merkle_root') != merkle_root:
print_error("merkle verification failed for", tx_hash)
self.print_error("merkle verification failed for", tx_hash)
return
# we passed all the tests
@@ -135,7 +135,7 @@ class TxVerifier(util.DaemonThread):
timestamp = header.get('timestamp')
with self.lock:
self.verified_tx[tx_hash] = (tx_height, timestamp, pos)
print_error("verified %s"%tx_hash)
self.print_error("verified %s"%tx_hash)
self.storage.put('verified_tx3', self.verified_tx, True)
self.network.trigger_callback('updated')
@@ -155,7 +155,7 @@ class TxVerifier(util.DaemonThread):
for tx_hash, item in items:
tx_height, timestamp, pos = item
if tx_height >= height:
print_error("redoing", tx_hash)
self.print_error("redoing", tx_hash)
with self.lock:
self.verified_tx.pop(tx_hash)
if tx_hash in self.merkle_roots: