Skip to content

Commit

Permalink
Namecoin / AuxPoW: Optimize coinbase txid calculation in verify_auxpow.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Jul 1, 2018
1 parent 4fa905e commit 2d78e25
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/auxpow.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def verify_auxpow(header):

parent_block = auxpow['parent_header']
coinbase = auxpow['parent_coinbase_tx']
coinbase_hash = coinbase.txid()
coinbase_hash = fast_txid(coinbase)

chain_merkle_branch = auxpow['chain_merkle_branch']
chain_index = auxpow['chain_merkle_index']
Expand Down Expand Up @@ -300,3 +300,8 @@ def hex_to_int(s):
if (chain_index != index):
raise Exception('Aux POW wrong index')

# This is calculated the same as the Transaction.txid() method, but doesn't
# reserialize it.
def fast_txid(tx):
return bh2u(Hash(bfh(tx.raw))[::-1])

0 comments on commit 2d78e25

Please sign in to comment.