Skip to content

Iterators returned by fluent interface routines reset randomly #459

@amurashov

Description

@amurashov

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions