mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
routes fixing
This commit is contained in:
parent
00b02b0524
commit
b80109e093
3 changed files with 9 additions and 17 deletions
|
|
@ -14,13 +14,17 @@ import (
|
||||||
|
|
||||||
// GetTransaction gets txs
|
// GetTransaction gets txs
|
||||||
func GetTransaction(w http.ResponseWriter, r *http.Request) {
|
func GetTransaction(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
txHash := vars["txHash"]
|
||||||
|
fmt.Println(txHash)
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
getTxResponse := shyftdb.GetTransaction(blockExplorerDb)
|
getTxResponse := shyftdb.GetTransaction(blockExplorerDb, txHash)
|
||||||
|
fmt.Println(getTxResponse)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ var routes = Routes{
|
||||||
Route{
|
Route{
|
||||||
"GetTransaction",
|
"GetTransaction",
|
||||||
"GET",
|
"GET",
|
||||||
"/api/get_transaction",
|
"/api/get_transaction/{txHash}",
|
||||||
GetTransaction,
|
GetTransaction,
|
||||||
},
|
},
|
||||||
Route{
|
Route{
|
||||||
|
|
|
||||||
|
|
@ -513,20 +513,9 @@ func GetAllTransactions(sqldb *sql.DB) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetTransaction fn returns single tx
|
//GetTransaction fn returns single tx
|
||||||
func GetTransaction(sqldb *sql.DB) string {
|
func GetTransaction(sqldb *sql.DB, TxHash string) string {
|
||||||
sqlStatement := `SELECT
|
sqlStatement := `SELECT * FROM txs WHERE txhash=$1;`
|
||||||
txhash,
|
row := sqldb.QueryRow(sqlStatement, TxHash)
|
||||||
to_addr,
|
|
||||||
from_addr,
|
|
||||||
blockhash,
|
|
||||||
blocknumber,
|
|
||||||
amount,
|
|
||||||
gasprice,
|
|
||||||
gas,
|
|
||||||
txfee,
|
|
||||||
nonce
|
|
||||||
FROM txs WHERE nonce=$1;`
|
|
||||||
row := sqldb.QueryRow(sqlStatement, 1)
|
|
||||||
var txhash string
|
var txhash string
|
||||||
var to_addr string
|
var to_addr string
|
||||||
var from_addr string
|
var from_addr string
|
||||||
|
|
@ -546,7 +535,6 @@ func GetTransaction(sqldb *sql.DB) string {
|
||||||
&gas,
|
&gas,
|
||||||
&txfee,
|
&txfee,
|
||||||
&nonce)
|
&nonce)
|
||||||
|
|
||||||
tx := ShyftTxEntryPretty{
|
tx := ShyftTxEntryPretty{
|
||||||
TxHash: txhash,
|
TxHash: txhash,
|
||||||
To: to_addr,
|
To: to_addr,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue