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
|
||||
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"
|
||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
getTxResponse := shyftdb.GetTransaction(blockExplorerDb)
|
||||
getTxResponse := shyftdb.GetTransaction(blockExplorerDb, txHash)
|
||||
fmt.Println(getTxResponse)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ var routes = Routes{
|
|||
Route{
|
||||
"GetTransaction",
|
||||
"GET",
|
||||
"/api/get_transaction",
|
||||
"/api/get_transaction/{txHash}",
|
||||
GetTransaction,
|
||||
},
|
||||
Route{
|
||||
|
|
|
|||
|
|
@ -513,20 +513,9 @@ func GetAllTransactions(sqldb *sql.DB) string {
|
|||
}
|
||||
|
||||
//GetTransaction fn returns single tx
|
||||
func GetTransaction(sqldb *sql.DB) string {
|
||||
sqlStatement := `SELECT
|
||||
txhash,
|
||||
to_addr,
|
||||
from_addr,
|
||||
blockhash,
|
||||
blocknumber,
|
||||
amount,
|
||||
gasprice,
|
||||
gas,
|
||||
txfee,
|
||||
nonce
|
||||
FROM txs WHERE nonce=$1;`
|
||||
row := sqldb.QueryRow(sqlStatement, 1)
|
||||
func GetTransaction(sqldb *sql.DB, TxHash string) string {
|
||||
sqlStatement := `SELECT * FROM txs WHERE txhash=$1;`
|
||||
row := sqldb.QueryRow(sqlStatement, TxHash)
|
||||
var txhash string
|
||||
var to_addr string
|
||||
var from_addr string
|
||||
|
|
@ -546,7 +535,6 @@ func GetTransaction(sqldb *sql.DB) string {
|
|||
&gas,
|
||||
&txfee,
|
||||
&nonce)
|
||||
|
||||
tx := ShyftTxEntryPretty{
|
||||
TxHash: txhash,
|
||||
To: to_addr,
|
||||
|
|
|
|||
Loading…
Reference in a new issue