I have a sample go application running with tendermint. I would like to access the data Tendermint's blockchain stores in leveldb while both the application and the node are running.
I have tried to run a basic go script that iterates over the tx_index.db which stores the tx.hash and the corresponding result of every transaction. But when I try to run the script the program panics with an error message.
Here's the go script to iterate over the tx_index.db
package main
import (
"fmt"
"github.com/syndtr/goleveldb/leveldb"
)
func main() {
db, err := leveldb.OpenFile("tx_index.db", nil)
if err != nil {
panic(err)
}
iter := db.NewIterator(nil, nil)
for iter.Next() {
key := iter.Key()
h_key := fmt.Sprintf("%X", key)
value := iter.Value()
h_value := fmt.Sprintf("%X", value)
fmt.Printf("Key: %v
Value: %v
", h_key, h_value)
}
iter.Release()
err = iter.Error()
defer db.Close()
}
Upon running the above script while the application and the tendermint node are running. I get the following error message!
panic: resource temporarily unavailable
goroutine 1 [running]:
main.main()
$HOME/tendermint/data/read_db.go:11 +0x375
exit status 2
I am interested in accessing the tx_index.db while the application and tendermint node are running to get the transaction hash of the transactions performed.
PS: If it's feasible I'd like to know if there's a way to get tx.hash by accessing the tx_index.db by interacting with the tendermint node.