mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
verifier: if we fail to verify SPV proof, disconnect from server
This commit is contained in:
parent
4a88ca1a3a
commit
c49e563881
1 changed files with 3 additions and 8 deletions
|
@ -24,12 +24,11 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Sequence, Optional
|
from typing import Sequence, Optional
|
||||||
|
|
||||||
from aiorpcx import TaskGroup
|
from .util import ThreadJob, bh2u, VerifiedTxInfo
|
||||||
|
|
||||||
from .util import ThreadJob, bh2u, VerifiedTxInfo, aiosafe
|
|
||||||
from .bitcoin import Hash, hash_decode, hash_encode
|
from .bitcoin import Hash, hash_decode, hash_encode
|
||||||
from .transaction import Transaction
|
from .transaction import Transaction
|
||||||
from .blockchain import hash_header
|
from .blockchain import hash_header
|
||||||
|
from .interface import GracefulDisconnect
|
||||||
|
|
||||||
|
|
||||||
class MerkleVerificationFailure(Exception): pass
|
class MerkleVerificationFailure(Exception): pass
|
||||||
|
@ -94,14 +93,10 @@ class SPV(ThreadJob):
|
||||||
verify_tx_is_in_block(tx_hash, merkle_branch, pos, header, tx_height)
|
verify_tx_is_in_block(tx_hash, merkle_branch, pos, header, tx_height)
|
||||||
except MerkleVerificationFailure as e:
|
except MerkleVerificationFailure as e:
|
||||||
self.print_error(str(e))
|
self.print_error(str(e))
|
||||||
# FIXME: we should make a fresh connection to a server
|
raise GracefulDisconnect(e)
|
||||||
# to recover from this, as this TX will now never verify
|
|
||||||
return
|
|
||||||
# we passed all the tests
|
# we passed all the tests
|
||||||
self.merkle_roots[tx_hash] = header.get('merkle_root')
|
self.merkle_roots[tx_hash] = header.get('merkle_root')
|
||||||
try:
|
try:
|
||||||
# note: we could pop in the beginning, but then we would request
|
|
||||||
# this proof again in case of verification failure from the same server
|
|
||||||
self.requested_merkle.remove(tx_hash)
|
self.requested_merkle.remove(tx_hash)
|
||||||
except KeyError: pass
|
except KeyError: pass
|
||||||
self.print_error("verified %s" % tx_hash)
|
self.print_error("verified %s" % tx_hash)
|
||||||
|
|
Loading…
Add table
Reference in a new issue