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

US regulators open inquiry into Waymo self-driving automobile that struck youngster in California | Expertise

The US’s federal transportation regulator stated Thursday it had opened an investigation after a Waymo self-driving car struck a toddler close to an...

US robotaxis bear coaching for London’s quirks earlier than deliberate rollout this yr | London

American robotaxis as a consequence of be unleashed on London’s streets earlier than the tip of the yr have been quietly present process...

Nvidia CEO reveals new ‘reasoning’ AI tech for self-driving vehicles | Nvidia

The billionaire boss of the chipmaker Nvidia, Jensen Huang, has unveiled new AI know-how that he says will assist self-driving vehicles assume like...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here