Skip to content

Conversation

@ryanofsky
Copy link
Contributor

Change CCoinsViewCache::Cursor() method to return a cursor yielding the latest CCoins entries, instead of just previous entries prior to the last cache flush.

The CCoinsViewCache::Cursor method is not currently used. This change just enables new features that rely on scanning the UXTO set to work correctly (for example #9152, which adds a sweepprivkeys RPC, and #9137, which improves handling of imported keys for nodes with pruning enabled.)

@sipa
Copy link
Member

sipa commented Dec 10, 2016

Concept ACK

@laanwj laanwj added this to the 0.15.0 milestone Feb 6, 2017
@laanwj
Copy link
Member

laanwj commented Jun 6, 2017

The CCoinsViewCache::Cursor method is not currently used

GetUTXOStats uses it.
Currently it makes use of the fact that it iterates over the current database instead of the in-memory data.
Leveldb can do an iteration in the background, as it makes a snapshot.
This change means that it can no longer run in the background, and needs the appropriate lock on pCoinsTip to prevent concurrent changes.

@sipa
Copy link
Member

sipa commented Jun 6, 2017

My hope is that at some point we can switch to a rolling UTXO hash (see my MuHash PR, and mailinglist thread), so gettxoutsetinfo does not need to interate over the set anymore but compute everything using continuously updated stats.

@sipa
Copy link
Member

sipa commented Jun 6, 2017

It's probably better to not merge this until we can rid of the necessity to iterate over the entire set in gettxoutsetinfo. And when we do, maybe this PR isn't needed anymore?

@ryanofsky
Copy link
Contributor Author

Probably this PR isn't needed unless #9152 or #9137 or something similar will be added. But I do think the fact that CCCoinsViewCache::Cursor() returns a cursor that doesn't actually iterate over the latest data in the view is confusing and could lead to bugs. Opened #10550 for a more direct solution to that problem.

Change CCoinsViewCache::Cursor() method to return a cursor yielding the latest
CCoins entries, instead of just previous entries prior to the last cache flush.

The CCoinsViewCache::Cursor method is not currently used. This change just
enables new features that rely on scanning the UXTO set to work correctly (for
example bitcoin#9152, which adds a
sweepprivkeys RPC, and bitcoin#9137, which
improves handling of imported keys for nodes with pruning enabled.)
@sipa
Copy link
Member

sipa commented Jun 12, 2017

I think #10550 is sufficient for now, and we won't need this until there is an actual use for iterating the UTXO set in a non-well-defined order?

@ryanofsky
Copy link
Contributor Author

All right, I'm not really working on #9137 anyway, will close.

@ryanofsky ryanofsky closed this Jun 12, 2017
@ryanofsky
Copy link
Contributor Author

@jonasschnelli, do you think this PR might be useful for your "scantxoutset" RPC (https://botbot.me/freenode/bitcoin-core-dev/msg/94684446/). It makes CCoinsViewCache::Cursor() return the latest data instead of stale data.

@ryanofsky
Copy link
Contributor Author

@jonasschnelli, do you think this PR might be useful for your "scantxoutset" RPC

Followup: Code is currently calling FlushStateToDisk so this should not be needed (https://botbot.me/freenode/bitcoin-core-dev/msg/94920590/)

@ryanofsky
Copy link
Contributor Author

Followup: Flush was removed according to https://botbot.me/freenode/bitcoin-core-dev/msg/95804751/ so this PR might be useful again. Implementation in #12196 does include a flush though, currently.

@jonasschnelli
Copy link
Contributor

This is definitively useful (could lead to removing the state flush in #12196).
@ryanofsky: Would be great if you'd like to reopen this (need probably rebase).

@maflcko
Copy link
Member

maflcko commented Apr 28, 2020

Should this be marked "Up for grabs"? cc @ryanofsky

@maflcko maflcko removed this from the 0.15.0 milestone Apr 28, 2020
@ryanofsky
Copy link
Contributor Author

Should this be marked "Up for grabs"? cc @ryanofsky

I don't know if the PR is up for grabs, more like uses of the PR are up for grabs. My motivation for this PR was let to wallet scan utxo set instead of blocks, and be able to get wallet balance if not full transaction history with a pruned node. Sipa, laanwj, and jonas above and luke in #9152 had other potential uses. The PR itself is simple and probably very easy to rebase. Just doesn't make sense without a use-case

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants