Closed bhemen closed 4 years ago
Logical and
, or
and not
don't work with the proxy interface, unfortunately. You need to use the bitwise operators &
, |
and ~
instead.
So, instead of
chain.addresses(blocksci.address_type.pubkey).where(lambda a: a.in_txes_count() == 0 and a.out_txes_count() == 1)
use
chain.addresses(blocksci.address_type.pubkey).where(lambda a: (a.in_txes_count() == 0) & (a.out_txes_count() == 1))
import blocksci
chain = blocksci.Blockchain("/blocksci/testchain.json")
len(chain)
250000
chain.addresses(blocksci.address_type.pubkey).where(lambda a: a.in_txes_count() == 0 and a.out_txes_count() == 1).size
194169
chain.addresses(blocksci.address_type.pubkey).where(lambda a: (a.in_txes_count() == 0) & (a.out_txes_count() == 1)).size
38247
all_addresses = chain.addresses(blocksci.address_type.pubkey) filtered_addresses = [a for a in all_addresses if a.in_txes_count() == 0 and a.out_txes_count() == 1] len(filtered_addresses)
38247
I'm getting inconsistent results when filtering addresses using a 'where.'
For example, suppose I want to get the list of addresses that have exactly one input and one output. I tried
The code above runs, but gives very different results from
I would have expected them to give essentially the same results.
The where query is not behaving as I'd expect because the range returned seems to be the same when I change the filters (see below).
Reproduction Steps
The outputs are
Notice that all the where queries seem to return the same number of results. Is this the correct way to use 'where'?
Thanks for your help.
System Information
Using AMI: No BlockSci version: 0.6 (fc34ac3) Blockchain: Bitcoin Parser: Disk Total memory: 128 GB