Remove altcoin-only server and tx code
Deletes the transaction deserializers of other coins (tx.py keeps only the Bitcoin/segwit ones), tx_dash.py, tx_axe.py, and the session, daemon and block processor subclasses that only other coins used. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
73c96101bd
commit
05f5fc9058
6 files changed
+3
-2745
No files matched your search
@@ -904,107 +904,3 @@ class BlockProcessor:
|
||||
self.blocks_event.set()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class DecredBlockProcessor(BlockProcessor):
|
||||
async def calc_reorg_range(self, count):
|
||||
start, count = await super().calc_reorg_range(count)
|
||||
if start > 0:
|
||||
# A reorg in Decred can invalidate the previous block
|
||||
start -= 1
|
||||
count += 1
|
||||
return start, count
|
||||
|
||||
|
||||
class NameIndexBlockProcessor(BlockProcessor):
|
||||
|
||||
def advance_txs_process_outputs(
|
||||
self,
|
||||
txs: Sequence[Tx],
|
||||
*,
|
||||
height: int,
|
||||
) -> None:
|
||||
result = super().advance_txs_process_outputs(txs, height=height)
|
||||
|
||||
tx_num_start = self.db.tx_counts[height - 1] if height > 0 else 0
|
||||
tx_num = tx_num_start
|
||||
script_name_hashX = self.coin.name_hashX_from_script
|
||||
update_touched_hashxs = self.touched_hashxs.update
|
||||
hashXs_by_tx = []
|
||||
append_hashXs = hashXs_by_tx.append
|
||||
|
||||
for tx in txs:
|
||||
hashXs = []
|
||||
append_hashX = hashXs.append
|
||||
|
||||
# Add the new UTXOs and associate them with the name script
|
||||
for txout in tx.outputs:
|
||||
# Get the hashX of the name script. Ignore non-name scripts.
|
||||
hashX = script_name_hashX(txout.pk_script)
|
||||
if hashX:
|
||||
append_hashX(hashX)
|
||||
|
||||
append_hashXs(hashXs)
|
||||
update_touched_hashxs(hashXs)
|
||||
tx_num += 1
|
||||
|
||||
self.db.history.add_unflushed(hashXs_by_tx, tx_num_start)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class LTORBlockProcessor(BlockProcessor):
|
||||
# for Lexicographical Transaction ordering in blocks
|
||||
# (as opposed to Topological order as used in Bitcoin)
|
||||
# note: the base class already does not care about tx ordering inside a block
|
||||
# for the forward (catch-up) direction, as that better parallelizes.
|
||||
# This subclass is only kept for the reverse (backup) direction, for now.
|
||||
# We could also parallelize backup_txs in the base class for better perf,
|
||||
# likely removing the tx ordering assumptions, then we could rm this subclass.
|
||||
|
||||
def backup_txs(self, txs, is_unspendable):
|
||||
undo_info = self.db.read_undo_info(self.height)
|
||||
if undo_info is None:
|
||||
raise ChainError(
|
||||
f'no undo information found for height {self.height:,d}'
|
||||
)
|
||||
|
||||
# Use local vars for speed in the loops
|
||||
put_utxo = self.utxo_cache.__setitem__
|
||||
spend_utxo = self.spend_utxo
|
||||
add_touched_hashx = self.touched_hashxs.add
|
||||
add_touched_outpoint = self.touched_outpoints.add
|
||||
undo_entry_len = HASHX_LEN + TXNUM_LEN + 8
|
||||
|
||||
# Restore coins that had been spent
|
||||
# (may include coins made then spent in this block)
|
||||
n = 0
|
||||
for tx in txs:
|
||||
for txin in tx.inputs:
|
||||
if txin.is_generation():
|
||||
continue
|
||||
undo_item = undo_info[n:n + undo_entry_len]
|
||||
prevout = txin.prev_txid_rev + pack_txoutidx(txin.prev_idx)
|
||||
put_utxo(prevout, undo_item)
|
||||
add_touched_hashx(undo_item[:HASHX_LEN])
|
||||
add_touched_outpoint((txin.prev_txid_rev, txin.prev_idx))
|
||||
n += undo_entry_len
|
||||
|
||||
assert n == len(undo_info)
|
||||
|
||||
# Remove tx outputs made in this block, by spending them.
|
||||
for tx in txs:
|
||||
txid_rev = tx.txid_rev
|
||||
for idx, txout in enumerate(tx.outputs):
|
||||
# Spend the TX outputs. Be careful with unspendable
|
||||
# outputs - we didn't save those in the first place.
|
||||
if is_unspendable(txout.pk_script):
|
||||
continue
|
||||
|
||||
# Get the hashX
|
||||
cache_value = spend_utxo(txid_rev, idx)
|
||||
hashX = cache_value[:HASHX_LEN]
|
||||
add_touched_hashx(hashX)
|
||||
add_touched_outpoint((txid_rev, idx))
|
||||
|
||||
self.tx_count -= len(txs)
|
||||
Reference in new issue
Block a user