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

Store and count the total number of outputs traversed when building the index #525

Merged
merged 8 commits into from
Sep 19, 2022

Conversation

raphjaph
Copy link
Collaborator

@raphjaph raphjaph commented Sep 12, 2022

I'm unsure about how to properly store a single value persistently in the database. In its own table? What should the key be? Or I make a table HEIGHT_TO_NUM_OUTPUTS that tracks how many outputs there are per block and then I just add up those values in the info command?

#487

@raphjaph
Copy link
Collaborator Author

raphjaph commented Sep 13, 2022

If you search for an outpoint that has been spent you get the following error message on the website

https://ordinals.com/output/969d68907f0e2aeacb8b17979fa48ea3b817cc5bfc92b1675326b3c170991c88:0
Output unknown. (maybe change to Output already spent so it contains no Ordinals)

Which makes sense. So the final database is an index of all UTXOs to ordinal ranges not an index of all outpoints to ordinal ranges. Maybe we should make that clearer in the code and also on the website.

Is this correct?

All UTXOs are outpoints but not all outpoints are UTXOs

Copy link
Collaborator

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good! We should create a general statistics table, with a dedicated enum as the key.

src/index.rs Outdated Show resolved Hide resolved
src/index.rs Outdated Show resolved Hide resolved
src/index.rs Outdated Show resolved Hide resolved
src/index.rs Outdated Show resolved Hide resolved
src/index.rs Outdated Show resolved Hide resolved
src/index.rs Outdated Show resolved Hide resolved
@raphjaph raphjaph marked this pull request as ready for review September 15, 2022 00:36
@raphjaph
Copy link
Collaborator Author

raphjaph commented Sep 15, 2022

Just ran this on signet:

blocks indexed: 108159
utxos indexed: 1370410
outputs traversed: 3801139
tree height: 5
free pages: 268249225
stored: 89.54 MiB
overhead: 10.73 MiB
fragmented: 561.19 MiB
index size: 2.5 GiB

Bitcoin-cli tells me that signet only has 1.24mil utxos. Are we maybe counting something wrong? Unspendable outputs?

 bitcoin-cli -chain=signet gettxoutsetinfo
{
  "height": 108160,
  "bestblock": "0000002321f73b11485d4b642535bd7fd0d349fc2e2f0dc2223e50c096dd5e28",
  "txouts": 1243877,
  "bogosize": 99780304,
  "hash_serialized_2": "f03a81c527f80b7527bb6f3e312dc9cde360f35ed2cb7c9bf892c97fc4522579",
  "total_amount": 5407999.99984400,
  "transactions": 1223288,
  "disk_size": 98571150
}

@raphjaph raphjaph force-pushed the count-outputs-traversed branch from 385a269 to e1c22ea Compare September 19, 2022 17:47
@casey casey merged commit 65cc509 into ordinals:master Sep 19, 2022
@raphjaph raphjaph deleted the count-outputs-traversed branch September 20, 2022 18:34
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