Bitcoin Forum
November 05, 2024, 10:33:16 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Get hash of oldest stored block (Core pruned mode)?  (Read 172 times)
jnano (OP)
Member
**
Offline Offline

Activity: 301
Merit: 74


View Profile
June 10, 2018, 04:10:20 PM
 #1

With Core in pruned mode, is there a command to get the hash of the oldest stored block?




cellard
Legendary
*
Offline Offline

Activity: 1372
Merit: 1252


View Profile
June 10, 2018, 05:48:17 PM
 #2

With Core in pruned mode, is there a command to get the hash of the oldest stored block?






I don't think so. It would be an interesting command to have. If there isn't, and until then, you can manually check it by subtracting N from current last block height, N being the number that you entered in the "prune=N" setting in your bitcoin.conf

So do:

getblockcount

This will give you the latest block you have. For instance for me right now is 526788, so let's say your prune N value is 550

526788-550=526238

getblockhash 526238

And there you go. If you try to get the hash of a block that is behind N you should get an error, something like "block not available (pruned data)".

A cvar that automates these steps could be added I guess.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6885


Just writing some code


View Profile WWW
June 10, 2018, 07:58:30 PM
Merited by Foxpup (2)
 #3

getblockchaininfo will tell you the height of the oldest stored complete block. You can then look up its hash using getblockhash.

jnano (OP)
Member
**
Offline Offline

Activity: 301
Merit: 74


View Profile
June 10, 2018, 08:29:53 PM
Last edit: June 10, 2018, 08:49:34 PM by jnano
 #4

Thanks.

getblockchaininfo's pruneheight property is indeed it.

cellard, that subtraction assumes each block is exactly 1MB, and that pruning keeps exactly the prune target in raw block data.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!