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

Updating the UTXO set at each block #108

Closed
nelsontodd opened this issue May 7, 2018 · 2 comments
Closed

Updating the UTXO set at each block #108

nelsontodd opened this issue May 7, 2018 · 2 comments

Comments

@nelsontodd
Copy link
Contributor

nelsontodd commented May 7, 2018

I work at Unchained Capital and I'm trying to recreate a copy of our UTXO Age Distribution.

I need to iterate over the UTXO set at each block and group the UTXOs by their age. I see the outputsUnspent method of the Blockchain class but this only allows iteration over the current UTXO set, and not historical snapshots of it.

I see in your paper (Fig. 13) that you calculate a timeseries of the percentage BTC unspent in the previous month -- how did you use BlockSci to extract this data? If you could share sample code that would be great.

I understand why caching the UTXO set at each block is not a default behavior of BlockSci (lots of space!). I would like to be able to turn on this behavior if possible.

@hkalodner
Copy link
Collaborator

Hi @nelsontodd,

I thought recreating this graph was an interesting challenge so I took a swing at doing this myself. For queries such as these I've found the optimal approach is to reduce the problem into calculating the net change per block rather than defining it on the UTXO pool at each height. I've written some code previously that produces a rolling UTXO pool object that can advance blocks and changes, but I haven't found a compelling use case for this feature.

Some of it is a bit convoluted and I there certainly might be some minor bugs, but the linked gist shows a solution to this problem which runs in a little under 3 minutes on our r4.2xlarge EC2 instance.

https://gist.github.com/hkalodner/b389a5009969de6b6141031829c9640b

Here's the graph which it generates. It looks like it matches up nicely with your own.

utxo_age

@nelsontodd
Copy link
Contributor Author

Thanks! That looks great. It never occurred to me to do it that way. I'm currently trying to reproduce your script on my own ec2 instance. I'll let you know as soon as I do.

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

No branches or pull requests

2 participants