0

I am trying to download a block(Height:474044) using an API from here in python. Block is obviously downloaded in JSON format. But when I store it in a file on my system it shows very weird size number, not matching with actual blocksize on network. I also tried to download data in hex format using this link. But still, when I try to store it in a file(JSON/Text), It is not showing the size same as shown in block details officially. I have intentionally chosen a block before segwit BIP to avoid any further confusion. Help me to confirm my downloaded blocksize with actually mentioned on network. This question might seem naive to some users as I am new to bitcoin. Thanks for help in advance.

2
  • What size do you see? Feb 25, 2020 at 11:38
  • Actual Block Size=998198, JSON File Size Stored on My System=5866321, Binary File Size Stored on My System=1996396. All sizes are in bytes.
    – wowfactory
    Feb 25, 2020 at 11:57

1 Answer 1

1

For one, there is no JSON block format - different APIs have different ways of interpreting and displaying a block in a JSON response, and none of them will ever match the block size.

Your mistake appears to be saving the actual hex block as text.

1996396 = 2 * 998198

You must write the data as an actual binary file. i.e., write 12 as the byte 0x12, instead of saving the text "12" directly, which will write the bytes 0x3132 to disk, doubling the size of the file saved. Saving it as text will double the file size, as you've noticed already.

1
  • Yeah. Seems about right. Thanks!!
    – wowfactory
    Feb 26, 2020 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.