Skip to content
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

rescan: only fetch blocks w/ witness data if we matched on an outpoint #64

Open
4 tasks
Roasbeef opened this issue Jul 8, 2018 · 0 comments
Open
4 tasks

Comments

@Roasbeef
Copy link
Member

Roasbeef commented Jul 8, 2018

One benefit of the switch to segwit, is that light clients are able to fetch blocks without witness data if they don't actually need access to the witness items. However, we don't currently take advantage of the optimization. As a result, our bandwidth usage is higher than it actually should be.

In lnd (the biggest user of this project), we only need access to the witness data of a block if we're attempting to extract the pre-image from the witness of an htlc success sweeping transaction. In all other cases, we can do just fine with only the witness data. We should expose this information to callers of the rescan API to allow them to signal if they'd like the block w/ full witness data if the outpoint in question matters. Note that in the near future, we'll switch to matching on the previous output scripts instead.

Steps To Completion

  • Modify the rescan logic to store previous output scripts and output scripts in distinct slice .

  • When matching a block, only fetch the block w/ witness data if a previous output script matched. Note that this means we should always first match the previous output scripts to ensure that we don't miss any witness data.

  • If the filter does match an input, then we should fetch the block w/ witness data. Otherwise, just fetch the regular block.

  • Similarly, the GetUtxo method should be modified to add an additional functional parameter to allow callers to signal if they would like the spending transaction (if it exists) with witness data or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant