mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
fix issue with opening db file
This commit is contained in:
parent
dfa0d2a18e
commit
da3abe13d6
2 changed files with 15 additions and 6 deletions
|
|
@ -5,9 +5,11 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
logger "log"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||
"github.com/ethereum/go-ethereum/shyftdb"
|
||||
)
|
||||
|
||||
// GetAllTransactions gets txs
|
||||
|
|
@ -55,13 +57,20 @@ func GetBalances(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// GetBlocksMined get blocks mined
|
||||
func GetBlocksMined(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
address := vars["address"]
|
||||
|
||||
blockExplorerDb, err := leveldb.OpenFile("./shyftData/geth/blockExplorerDb/", &opt.Options{
|
||||
ErrorIfMissing: true,
|
||||
ReadOnly: true,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Print(err)
|
||||
return
|
||||
}
|
||||
blocks := shyftdb.GetAllBlocks(blockExplorerDb)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintln(w, "Get Blocks Mined", address)
|
||||
fmt.Fprintln(w, "Get Blocks Mined", blocks)
|
||||
}
|
||||
|
||||
// GetTransactions gets txs
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ var routes = Routes{
|
|||
Route{
|
||||
"GetBlocksMined",
|
||||
"GET",
|
||||
"/api/get_blocks_mined/{address}",
|
||||
"/api/get_blocks_mined",
|
||||
GetBlocksMined,
|
||||
},
|
||||
Route{
|
||||
|
|
|
|||
Loading…
Reference in a new issue