blockchain – Improper hashes for blocks when parsing from blk

on

|

views

and

comments


Hiya I am utilizing a python script to truly retrieve info from a blk file and to learn information.

import datetime

# Learn block !
file = open("REDACTEDblocksblk00000.dat", 'rb')

numberOfBlocks = 0
i = 0
toAnalyse = 5000

whereas i < toAnalyse:  

    block_magic_bytes = file.learn(4)
    
    if b''==block_magic_bytes :
        break
    
    block_size = file.learn(4)
    block_size_int = int.from_bytes(block_size,'little')
    block_version = file.learn(4)
    block_lastblock = file.learn(32)
    block_lastblock_little_endian = int.from_bytes(block_lastblock,'little') 

    # merkle root
    file.search(32,1)

    block_time = int.from_bytes(file.learn(4),'little')

    #bits
    file.search(4,1)

    block_nonce = int.from_bytes(file.learn(4),'little')

    # Prints some info
    print("Block quantity   : " + str(numberOfBlocks))
    print(numberOfBlocks)

    print("Magic bytes    : " + block_magic_bytes.hex(" ").higher())
    print("Block dimension hex : " + block_size.hex(" ").higher())
    print("Block dimension int : " + str(block_size_int))
    print("Block model  : " + block_version.hex(" "))
    print( f'Block preBlock : {block_lastblock_little_endian:064x}' )
    print("Block time     : " + str(datetime.datetime.fromtimestamp(block_time)))
    print("Block nonce    : " + str(block_nonce))
    print()

    # Jumps to subsequent magic_bytes
    file.search(block_size_int-4-32-32-4-4-4,1)

    numberOfBlocks+=1
    i+=1
print("Final block learn")

However once I learn the block 486 within the blk file I get this :

Block quantity   : 486
486
Magic bytes    : F9 BE B4 D9
Block dimension hex : D8 00 00 00
Block dimension int : 216
Block model  : 01 00 00 00
Block preBlock : 00000000806df68baab17e49e567d4211177fef4849ffd8242d095c6a1169f45
Block time     : 2009-01-14 22:27:29
Block nonce    : 2063568441

As I perceive the BTC blockchain the earlier hash must be the hash of the block with top 485, however once I look utilizing an explorer that is the hash of block 499 : https://www.blockchain.com/btc/block/00000000806df68baab17e49e567d4211177fef4849ffd8242d095c6a1169f45

Is it that blocks aren’t so as in blk information ? Are my blk information unsuitable ? I downloaded them utilizing bitcoin-core. Are some blocks really not included within the general blockchain ?

I’d recognize any pointers,suggestions or assist after all ^^

Share this
Tags

Must-read

Constructing the Torc Driverless Security Case

At Torc, we’ve structured our security case on three foundational pillars: Engineer It to Be Secure, Function It to Be Secure, and the...

What’s DL+S? Unlocking the Huge Information Required to Develop Autonomous Vans

Breakthroughs in AI for autonomous driving don't occur in isolation. They occur when information, simulation, machine studying, infrastructure, and car testing work as...

Why I can’t wait to get right into a driverless automotive | Self-driving automobiles

Adrian Chiles (Driverless automobiles are taking us on a street to nowhere, 10 September) needs to know who requested for driverless automobiles. I...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here