user84599: According to this post: What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?
One type of the keys in leveldb of bitcoin is formed in the following way

'b' + 32-byte block hash

I wrote the following code in go but I got "not found".
genesisBlockHash := "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
hashBytes, _ := hex.DecodeString(genesisBlockHash)
keyBytes := append([]byte("b"), hashBytes...)
data, err := db.Get(keyBytes, nil)

Where did I do wrong? How can I add 'b' to the hash?

Tried a simple case: 

'R' -> 1-byte boolean ('1' if true): whether we're in the process of reindexing.

Go code
data, err := db.Get([]byte("R"), nil)

But I still got "not found". Why...

Tried file. 

'f' + 4-byte file number -> file information record. 

I could get some data. I think the following code should retrieve the "blk00000.dat" block file information, right?
readFile(db, []byte{0, 0, 0, 0})

func readFile(db *leveldb.DB, file []byte) {
    data, err := db.Get(append([]byte("f"), file...), nil)
    if err != nil {
        log.Println(err)
        os.Exit(1)
    }
    // read data
}


user48884: 
Where did I do wrong? How can I add 'b' to the hash?

The block hashes need to be byteswapped. Instead of 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f, you should have 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000.

But I still got "not found". Why...

This key-value pair is not always present.

I could get some data. I think the following code should retrieve the "blk00000.dat" block file information, right?

Yes.

84599: <p>According to this post: <a href="https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair">What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?</a></p>

<p>One type of the keys in leveldb of bitcoin is formed in the following way</p>

<blockquote>
  <p>'b' + 32-byte block hash</p>
</blockquote>

<p>I wrote the following code in go but I got "not found".</p>

<pre><code>genesisBlockHash := "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
hashBytes, _ := hex.DecodeString(genesisBlockHash)
keyBytes := append([]byte("b"), hashBytes...)
data, err := db.Get(keyBytes, nil)
</code></pre>

<p>Where did I do wrong? How can I add <code>'b'</code> to the hash?</p>

<hr>

<p>Tried a simple case: </p>

<blockquote>
  <p>'R' -> 1-byte boolean ('1' if true): whether we're in the process of reindexing.</p>
</blockquote>

<p>Go code</p>

<pre><code>data, err := db.Get([]byte("R"), nil)
</code></pre>

<p>But I still got "not found". Why...</p>

<hr>

<p>Tried file. </p>

<blockquote>
  <p>'f' + 4-byte file number -> file information record. </p>
</blockquote>

<p>I could get some data. I think the following code should retrieve the "blk00000.dat" block file information, right?</p>

<pre><code>readFile(db, []byte{0, 0, 0, 0})

func readFile(db *leveldb.DB, file []byte) {
    data, err := db.Get(append([]byte("f"), file...), nil)
    if err != nil {
        log.Println(err)
        os.Exit(1)
    }
    // read data
}
</code></pre>
 48884: <blockquote>
  <p>Where did I do wrong? How can I add '<code>b'</code> to the hash?</p>
</blockquote>

<p>The block hashes need to be byteswapped. Instead of <code>000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f</code>, you should have <code>6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000</code>.</p>

<blockquote>
  <p>But I still got "not found". Why...</p>
</blockquote>

<p>This key-value pair is not always present.</p>

<blockquote>
  <p>I could get some data. I think the following code should retrieve the "blk00000.dat" block file information, right?</p>
</blockquote>

<p>Yes.</p>
