Browse Source

logging: some extra network-related lines

3.1
SomberNight 7 years ago
parent
commit
02c7524d75
  1. 3
      lib/blockchain.py
  2. 5
      lib/network.py
  3. 16
      lib/verifier.py

3
lib/blockchain.py

@ -226,6 +226,9 @@ class Blockchain(util.PrintError):
if truncate and offset != self._size*80:
f.seek(offset)
f.truncate()
self.print_error(
'write. truncating to offset {}, which is around chunk {}'
.format(offset, offset//80//2016))
f.seek(offset)
f.write(data)
f.flush()

5
lib/network.py

@ -549,7 +549,7 @@ class Network(util.DaemonThread):
self.donation_address = result
elif method == 'mempool.get_fee_histogram':
if error is None:
self.print_error(result)
self.print_error('fee_histogram', result)
self.config.mempool_fees = result
self.notify('fee_histogram')
elif method == 'blockchain.estimatefee':
@ -784,7 +784,10 @@ class Network(util.DaemonThread):
index = params[0]
# Ignore unsolicited chunks
if index not in self.requested_chunks:
interface.print_error("received chunk %d (unsolicited)" % index)
return
else:
interface.print_error("received chunk %d" % index)
self.requested_chunks.remove(index)
connect = blockchain.connect_chunk(index, result)
if not connect:

16
lib/verifier.py

@ -74,10 +74,18 @@ class SPV(ThreadJob):
pos = merkle.get('pos')
merkle_root = self.hash_merkle_root(merkle['merkle'], tx_hash, pos)
header = self.network.blockchain().read_header(tx_height)
if not header or header.get('merkle_root') != merkle_root:
# FIXME: we should make a fresh connection to a server to
# recover from this, as this TX will now never verify
self.print_error("merkle verification failed for", tx_hash)
# FIXME: if verification fails below,
# we should make a fresh connection to a server to
# recover from this, as this TX will now never verify
if not header:
self.print_error(
"merkle verification failed for {} (missing header {})"
.format(tx_hash, tx_height))
return
if header.get('merkle_root') != merkle_root:
self.print_error(
"merkle verification failed for {} (merkle root mismatch {} != {})"
.format(tx_hash, header.get('merkle_root'), merkle_root))
return
# we passed all the tests
self.merkle_roots[tx_hash] = merkle_root

Loading…
Cancel
Save