Skip to content

More split-outs from UTXO hasher #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2021

Conversation

domob1812
Copy link

@domob1812 domob1812 commented Jun 29, 2021

This is a set of two more independent changes split out from #80:

  • Use TransactionLocationReference more consistently in the code; instead of passing around raw transaction heights in some places, pass in the TransactionLocationReference
  • Define a new CTxMemPool::lookupOutpoint method, which looks up a mempool transaction by the outpoint for spending (what will be the UTXO hash in the future)
  • Some more unit tests for the mempool

This refactors some parts of the code (mainly the UTXO tracking) to use
TransactionLocationReference more consistently instead of e.g. ad-hoc
passing of a raw block height.  Describing the "details" of a transaction
in the blockchain (including transaction hash and confirmed block height)
is what TransactionLocationReference is meant for, so this makes sense.

With these changes, it will also be easier to use the UTXO hash of a
transaction in the future, as that will just be added seamlessly to
TransactionLocationReference and then won't need to be customarily
wired through.
The memory pool mainly tracks transactions by txid; however, in some
places, we actually need to look up the transaction by the output hash
it creates (which will be different from the txid after segwit light).

This introduces a new method CTxMemPool::lookupOutpoint, which is meant
to be used for these situations (even though for now it does the same
as lookup).  It also updates the code to use the new method where
this is appropriate.
@galpHub
Copy link

galpHub commented Jun 30, 2021

Looks good overall. If you could add some additional mempool tests regarding CTxMemPool::lookup & CTxMemPool::exists for completeness, that would be awesome. Just so we front load the work of not breaking anything

This extends the mempool unit tests to explicitly verify lookup both
by normal and bare txid, the two exists calls (with normal and bare txid)
as well as the new lookupOutpoint method.
@galpHub galpHub merged commit 633aa16 into DiviProject:Development Jun 30, 2021
@domob1812 domob1812 deleted the tx-location-ref branch June 30, 2021 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants