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

Blockchain.map_blocks and Blockchain.range return different length objects #445

Open
carlocampajola opened this issue Nov 19, 2020 · 0 comments

Comments

@carlocampajola
Copy link

Hi,

first, thanks for the great work. This is a minor issue which i have encountered.

I have noticed that calling map_blocks between given dates/block numbers returns objects which are one block short of what is returned when calling for instance the range method with the same options. In particular it appears the map_blocks method skips the last block in the range. While this is easily amendable by adding one block to the end argument of map_blocks, it seems likely to cause confusion (or I might be confused).

Reproduction Steps

import blocksci

chain = blocksci.Blockchain( 'btc_cfgfile.ini' )
start_date = '2011-04-11'
end_date = '2011-04-12'

def mapFunc(block):
    return block.height

rangeobj = chain.range(start_date, end_date).height
mapobj = chain.map_blocks(mapFunc, start_date, end_date)

print(len(rangeobj)) ## returns 163
print(len(mapobj)) ## returns 162

print(rangeobj[-1]) ## returns 117894
print(mapobj[-1]) ## returns 117893

System Information

Using AMI: no
BlockSci version: v0.7
Blockchain: Bitcoin
Parser: Disk
Total memory: 128 GB

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