graphsense / graphsense-blocksci

A dockerized component to synchronize BlockSci data to Apache Cassandra
MIT License
20 stars 8 forks source link

Handle duplicated tx hashes #1

Closed defconst closed 3 years ago

defconst commented 5 years ago

Duplicated tx hashes:

import blocksci
chain = blocksci.Blockchain("/var/data/blocksci_data/btc.cfg")

#####
chain.tx_with_index(142572)
# Tx(len(txins)=0, len(txouts)=1, size_bytes=133, block_height=91722, tx_index=142572)
chain.tx_with_index(142572).hash
# e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468

chain.tx_with_index(142841)
# Tx(len(txins)=0, len(txouts)=1, size_bytes=133, block_height=91880, tx_index=142841)
chain.tx_with_index(142841).hash
# e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468

str(chain.tx_with_index(142572).hash) == str(blocksci.Tx(142841, chain).hash)
# True

######
chain.tx_with_index(142726)
# Tx(len(txins)=0, len(txouts)=1, size_bytes=133, block_height=91812, tx_index=142726)
chain.tx_with_index(142726).hash
# d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599

chain.tx_with_index(142783)
# Tx(len(txins)=0, len(txouts)=1, size_bytes=133, block_height=91842, tx_index=142783)
chain.tx_with_index(142783).hash
# d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599

str(chain.tx_with_index(142726).hash) == str(chain.tx_with_index(142783).hash)
# True

The primary key (tx_prefix, tx_hash) does not allow duplicates.

mdragaschnig commented 3 years ago

Has been resolved by updating the schema.