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

Iterators returned by fluent interface routines reset randomly #459

Open
amurashov opened this issue May 22, 2021 · 0 comments
Open

Iterators returned by fluent interface routines reset randomly #459

amurashov opened this issue May 22, 2021 · 0 comments

Comments

@amurashov
Copy link

Hello all!

I am trying to build a full graph (all the way back to miners) of one particular address, and I am doing smth like this:

import blocksci
import pandas
import numpy as np

chain = blocksci.Blockchain("/home/ubuntu/blocksci.conf")

test_address = chain.address_from_string('35pgGeez3ou6ofrpjt8T7bvC9t6RrUK4p6')

all_outputs  = test_address.outputs.where(lambda o: ~o.is_spent)
all_coinbase_txes = []

#the following part I was planning to put under the 'while' loop, however it does not work even with single-step
txes_cb  = all_outputs.where(lambda o:  o.tx.is_coinbase)
all_coinbase_txes = all_coinbase_txes + txes_cb.to_list()

txes_ncb = all_outputs.where(lambda o: ~o.tx.is_coinbase)

new_all_outputs = txes_ncb.select(lambda o: o.tx.inputs).select(lambda o: o.spent_output)

print ("New set: %d, old set: %d, final set: %d" % (new_all_outputs.size, all_outputs.size, len(all_coinbase_txes)))

all_outputs = new_all_outputs

It prints all zeros, which is obviously not correct - some internal states of iterators seem to be corrupted by such usage. I have assembled even simplier bug demonstration:

import blocksci
import pandas
import numpy as np

chain = blocksci.Blockchain("/home/ubuntu/blocksci.conf")

test_address = chain.address_from_string('35pgGeez3ou6ofrpjt8T7bvC9t6RrUK4p6')

all_outputs  = test_address.outputs.where(lambda o: ~o.is_spent)
print(all_outputs.size)
print(all_outputs.size)

prints first '146' and then '0'.

May be I am using it wrong?

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

1 participant