Blockchain.map_blocks and Blockchain.range return different length objects
carlocampajola opened this issue · comments
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