From 79e140e4cf82f5a4ef738f4834adbabac2e261ed Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 16 May 2018 12:02:51 -0400 Subject: [PATCH 1/5] writing contract address when isContract is true --- shyftDb/postgres_setup/create_tables.psql | 1 + shyftdb/shyft_database_util.go | 96 +++++++++++++---------- 2 files changed, 56 insertions(+), 41 deletions(-) diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyftDb/postgres_setup/create_tables.psql index 80afba9790..53863aa98b 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyftDb/postgres_setup/create_tables.psql @@ -26,6 +26,7 @@ CREATE TABLE IF NOT EXISTS txs ( txFee numeric, nonce numeric, isContract bool, + txStatus text, data bytea ); diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go index af3475d4d6..4540f8edc5 100644 --- a/shyftdb/shyft_database_util.go +++ b/shyftdb/shyft_database_util.go @@ -118,31 +118,31 @@ type SendAndReceive struct { blockNonce := block.Nonce() // Convert the receipts into their storage form and serialize them - storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) - for i, receipt := range receipts { - storageReceipts[i] = (*types.ReceiptForStorage)(receipt) - var txHashFromReciept = (*types.ReceiptForStorage)(receipt).TxHash - var statusFromReciept = (*types.ReceiptForStorage)(receipt).Status - var contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress - if statusFromReciept == 1 { - fmt.Println("THIS IS statusFromReciept", "SUCCESS", statusFromReciept) - } - if statusFromReciept == 0 { - fmt.Println("THIS IS statusFromReciept", "FAIL", statusFromReciept) - } - - if block.Transactions()[0].To() == nil { - updateSQLStatement := `UPDATE txs SET to_addr = ($2) WHERE txHash = ($1)` - _, error := sqldb.Exec(updateSQLStatement, txHashFromReciept.String(), contractAddressFromReciept.String()) - if error != nil { - panic(error) - } - } - - - fmt.Println("THIS IS txHashFromReciept", txHashFromReciept.String()) - fmt.Println("THIS IS contractAddressFromReciept", contractAddressFromReciept.String()) - } + //storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) + //for i, receipt := range receipts { + // storageReceipts[i] = (*types.ReceiptForStorage)(receipt) + // var txHashFromReciept = (*types.ReceiptForStorage)(receipt).TxHash + // //var statusFromReciept = (*types.ReceiptForStorage)(receipt).Status + // var contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress + // //if statusFromReciept == 1 { + // // fmt.Println("THIS IS statusFromReciept", "SUCCESS", statusFromReciept) + // //} + // //if statusFromReciept == 0 { + // // fmt.Println("THIS IS statusFromReciept", "FAIL", statusFromReciept) + // //} + // + // if block.Transactions()[0].To() == nil { + // updateSQLStatement := `UPDATE txs SET to_addr = ($2) WHERE txHash = ($1)` + // _, error := sqldb.Exec(updateSQLStatement, txHashFromReciept.String(), contractAddressFromReciept.String()) + // if error != nil { + // panic(error) + // } + // } + // + // + // //fmt.Println("THIS IS txHashFromReciept", txHashFromReciept.String()) + // //fmt.Println("THIS IS contractAddressFromReciept", contractAddressFromReciept.String()) + //} i, err := strconv.ParseInt(block.Time().String(), 10, 64) if err != nil { @@ -159,7 +159,7 @@ type SendAndReceive struct { if block.Transactions().Len() > 0 { for _, tx := range block.Transactions() { //WriteMinerRewards(sqldb, block) - WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String()) + WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts) if block.Transactions()[0].To() != nil { WriteFromBalance(sqldb, tx) } @@ -173,7 +173,7 @@ type SendAndReceive struct { } //WriteTransactions writes to sqldb -func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string) error { +func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt) error { txData := ShyftTxEntry{ TxHash: tx.Hash(), From: tx.From(), @@ -198,11 +198,25 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha data := txData.Data to := txData.To var isContract bool + var statusFromReciept string + if (to == nil){ + var contractAddressFromReciept string + for _, receipt := range receipts { + statusReciept := (*types.ReceiptForStorage)(receipt).Status + contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() + if statusReciept == 1 { + statusFromReciept = "SUCCESS" + } + if statusReciept == 0 { + statusFromReciept = "FAIL" + } + } + var retNonce string isContract = true - sqlStatement := `INSERT INTO txs(txhash, from_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11)) RETURNING nonce` - qerr := sqldb.QueryRow(sqlStatement, txHash, from, blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, data).Scan(&retNonce) + sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, txStatus, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13)) RETURNING nonce` + qerr := sqldb.QueryRow(sqlStatement, txHash, from, contractAddressFromReciept, blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, statusFromReciept, data).Scan(&retNonce) if qerr != nil { panic(qerr) @@ -210,8 +224,18 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha } else { var retNonce string isContract = false - sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12)) RETURNING nonce` - qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, data).Scan(&retNonce) + for _, receipt := range receipts { + statusReciept := (*types.ReceiptForStorage)(receipt).Status + if statusReciept == 1 { + statusFromReciept = "SUCCESS" + } + if statusReciept == 0 { + statusFromReciept = "FAIL" + } + } + + sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, txStatus, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13)) RETURNING nonce` + qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, statusFromReciept, data).Scan(&retNonce) if qerr != nil { panic(qerr) @@ -243,13 +267,6 @@ func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error { err := sqldb.QueryRow(sqlExistsStatement, fromAddr).Scan(&response) switch { case err == sql.ErrNoRows: - fmt.Println("NO ROWS RAN") - //i, err := strconv.Atoi(accountNonceSen) - //if err != nil { - // fmt.Println(err) - //} - //fmt.Println("accountnonce", i) - //fmt.Println(reflect.TypeOf(i)) sqlStatement := `INSERT INTO accounts(addr, balance, txCountAccount) VALUES(($1), ($2), ($3)) RETURNING addr` insertErr := sqldb.QueryRow(sqlStatement, fromAddr, amount, accountNonceSen).Scan(&fromAddr) if insertErr != nil { @@ -321,13 +338,10 @@ func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error { err := sqldb.QueryRow(sqlExistsStatement, toAddr).Scan(&response) switch { case err == sql.ErrNoRows: - fmt.Println("NO ROWS RAN") i, err := strconv.Atoi(accountNonceRec) if err != nil { fmt.Println(err) } - //fmt.Println("accountnonce", i) - //fmt.Println(reflect.TypeOf(i)) sqlStatement := `INSERT INTO accounts(addr, balance, txCountAccount) VALUES(($1), ($2), ($3)) RETURNING addr` insertErr := sqldb.QueryRow(sqlStatement, toAddr, amount, i).Scan(&toAddr) if insertErr != nil { From 844106b8d77ccfc2f59f7629b9e148586e4d3ab4 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 16 May 2018 12:20:59 -0400 Subject: [PATCH 2/5] fixed db order --- shyftDb/postgres_setup/create_tables.psql | 2 +- shyftdb/shyft_database_util.go | 59 ++++++----------------- 2 files changed, 17 insertions(+), 44 deletions(-) diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyftDb/postgres_setup/create_tables.psql index 53863aa98b..2e3a75d6c3 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyftDb/postgres_setup/create_tables.psql @@ -25,8 +25,8 @@ CREATE TABLE IF NOT EXISTS txs ( gas numeric, txFee numeric, nonce numeric, - isContract bool, txStatus text, + isContract bool, data bytea ); diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go index 4540f8edc5..d27502618e 100644 --- a/shyftdb/shyft_database_util.go +++ b/shyftdb/shyft_database_util.go @@ -80,6 +80,8 @@ type ShyftTxEntryPretty struct { Gas uint64 Cost uint64 Nonce uint64 + Status string + IsContract bool Data []byte } @@ -117,33 +119,6 @@ type SendAndReceive struct { blockSize := block.Size().String() blockNonce := block.Nonce() - // Convert the receipts into their storage form and serialize them - //storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) - //for i, receipt := range receipts { - // storageReceipts[i] = (*types.ReceiptForStorage)(receipt) - // var txHashFromReciept = (*types.ReceiptForStorage)(receipt).TxHash - // //var statusFromReciept = (*types.ReceiptForStorage)(receipt).Status - // var contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress - // //if statusFromReciept == 1 { - // // fmt.Println("THIS IS statusFromReciept", "SUCCESS", statusFromReciept) - // //} - // //if statusFromReciept == 0 { - // // fmt.Println("THIS IS statusFromReciept", "FAIL", statusFromReciept) - // //} - // - // if block.Transactions()[0].To() == nil { - // updateSQLStatement := `UPDATE txs SET to_addr = ($2) WHERE txHash = ($1)` - // _, error := sqldb.Exec(updateSQLStatement, txHashFromReciept.String(), contractAddressFromReciept.String()) - // if error != nil { - // panic(error) - // } - // } - // - // - // //fmt.Println("THIS IS txHashFromReciept", txHashFromReciept.String()) - // //fmt.Println("THIS IS contractAddressFromReciept", contractAddressFromReciept.String()) - //} - i, err := strconv.ParseInt(block.Time().String(), 10, 64) if err != nil { panic(err) @@ -199,7 +174,7 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha to := txData.To var isContract bool var statusFromReciept string - + if (to == nil){ var contractAddressFromReciept string for _, receipt := range receipts { @@ -324,8 +299,6 @@ func WriteContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndRe //WriteFromBalance writes senders balance to accounts db func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error { - //IF to address is nil (which means its contract creation) - //Need to create a condition (flag) check and then change how the nonce increment works sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := WriteBalanceHelper(sqldb, tx) toAddr := sendAndReceiveData.To fromAddr := sendAndReceiveData.From @@ -625,19 +598,7 @@ func GetAllTransactions(sqldb *sql.DB) string { var arr txRes var txx string rows, err := sqldb.Query(` - SELECT - txhash, - to_addr, - from_addr, - blockhash, - blocknumber, - amount, - gasprice, - gas, - txfee, - nonce, - data - FROM txs`) + SELECT * FROM txs`) if err != nil { fmt.Println("err") } @@ -653,6 +614,8 @@ func GetAllTransactions(sqldb *sql.DB) string { var gas uint64 var txfee uint64 var nonce uint64 + var status string + var isContract bool var data []byte err = rows.Scan( &txhash, @@ -665,6 +628,8 @@ func GetAllTransactions(sqldb *sql.DB) string { &gas, &txfee, &nonce, + &status, + &isContract, &data, ) @@ -679,6 +644,8 @@ func GetAllTransactions(sqldb *sql.DB) string { Gas: gas, Cost: txfee, Nonce: nonce, + Status: status, + IsContract: isContract, Data: data, }) @@ -703,6 +670,8 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { var gas uint64 var txfee uint64 var nonce uint64 + var status string + var isContract bool var data []byte row.Scan( &txhash, @@ -714,6 +683,8 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { &gas, &txfee, &nonce, + &status, + &isContract, &data) tx := ShyftTxEntryPretty{ TxHash: txhash, @@ -726,6 +697,8 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { Gas: gas, Cost: txfee, Nonce: nonce, + Status: status, + IsContract: isContract, Data: data, } json, _ := json.Marshal(tx) From a7af9c9255aa3f346c2383f2995279bbcfadd176 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 16 May 2018 15:23:08 -0400 Subject: [PATCH 3/5] updated getters and write fns for contextual data --- blockExplorerApi/handler.go | 2 - .../src/components/table/blocks/blockRows.js | 2 +- .../src/components/table/blocks/blockTable.js | 2 +- .../table/blocks/blocksDetailsRow.js | 2 + .../src/components/table/blocks/table.css | 5 ++ .../transactions/transactionDetailsRow.js | 71 +++++++++---------- .../table/transactions/transactionRow.js | 7 +- .../table/transactions/transactionTable.js | 7 +- shyftBlockExplorerUI/src/containers/App.js | 2 + shyftDb/postgres_setup/create_tables.psql | 2 + shyftdb/shyft_database_util.go | 66 ++++++++++------- 11 files changed, 94 insertions(+), 74 deletions(-) diff --git a/blockExplorerApi/handler.go b/blockExplorerApi/handler.go index abdc9acd31..2b5c3692c3 100644 --- a/blockExplorerApi/handler.go +++ b/blockExplorerApi/handler.go @@ -16,7 +16,6 @@ import ( 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 { @@ -24,7 +23,6 @@ func GetTransaction(w http.ResponseWriter, r *http.Request) { } getTxResponse := shyftdb.GetTransaction(blockExplorerDb, txHash) - fmt.Println(getTxResponse) if err != nil { http.Error(w, err.Error(), 500) diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js b/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js index 1258db7b55..900f3cf1d5 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js +++ b/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js @@ -24,7 +24,7 @@ class BlocksTable extends Component { render() { const table = this.state.data.map((data, i) => { return { return ( - + props.detailBlockHandler(props.Number)}> {props.Number} diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js index 74c45681a1..dc881a5b9c 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js @@ -8,6 +8,7 @@ class DetailBlockTable extends Component { let combinedClasses = ['responsive-table', classes.table]; return ( + @@ -68,6 +69,7 @@ class DetailBlockTable extends Component { +
Height: {data.Number}Reward: TBD
); } diff --git a/shyftBlockExplorerUI/src/components/table/blocks/table.css b/shyftBlockExplorerUI/src/components/table/blocks/table.css index 38f3d87fed..8aa8995a54 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/table.css +++ b/shyftBlockExplorerUI/src/components/table/blocks/table.css @@ -13,6 +13,11 @@ th { padding-right: 10px; } +td { + padding-left: 5px; + font-size: .5rem; +} + .addressTag { display: inline-block; vertical-align: bottom; diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js index a4d51fccb0..1ce7db2ac8 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js @@ -5,69 +5,64 @@ class DetailTransactionTable extends Component { render() { let data = this.props.data + console.log(data) let combinedClasses = ['responsive-table', classes.table]; return ( + - + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + +
TxHash: {data.TxHash}
Age:TxReceipt Status:{data.Status}
Block Height:{data.BlockNumber}
TimeStamp: {data.Age}
Txn:{data.TxCount} transactionsFrom:{data.From}
Block Hash:{data.Hash}To:{ `${data.IsContract}` ? `${data.To} (Contract)` : `${data.To}` }
Parent Hash:{data.ParentHash}Value:{data.Amount}
Uncle Hash:{data.UncleHash}
Uncle Count:{data.UncleCount}
Coinbase:{data.Coinbase}
Difficulty:{data.Difficulty}
GasUsed:{data.GasUsed}
Size:{data.Size}ytes
GasUsed:{data.GasUsed}
GasLimit:Gas Limit: {data.GasLimit}
Gas Used By Txn:{data.Gas}
Gas Price:{data.GasPrice}
Actual Tx Cost/Fee:{data.Cost}
Nonce: {data.Nonce}
Reward:TBDInput Data:{data.Data}
); } diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js index abde6e9bef..76bd341d5c 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js @@ -26,25 +26,28 @@ class TransactionTable extends Component { const table = this.state.data.map((data, i) => { return }) let combinedClasses = ['responsive-table', classes.table]; return ( - +
+ diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js index f8fb0d1713..2d3210b60c 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js @@ -4,6 +4,7 @@ import arrow from '../../assets/arrow_right.png'; import { Link } from 'react-router-dom' const TransactionTable = (props) => { + console.log(props) return ( @@ -12,10 +13,10 @@ const TransactionTable = (props) => { {props.txHash} - + - - + + diff --git a/shyftBlockExplorerUI/src/containers/App.js b/shyftBlockExplorerUI/src/containers/App.js index 6029f37e68..b794f9283f 100644 --- a/shyftBlockExplorerUI/src/containers/App.js +++ b/shyftBlockExplorerUI/src/containers/App.js @@ -32,8 +32,10 @@ class App extends Component { } detailTransactionHandler = async(txHash) => { + console.log("THIS RAN") try { const response = await axios.get(`http://localhost:8080/api/get_transaction/${txHash}`) + console.log("THIS IS RESPONSE", response) await this.setState({ transactionDetailData: response.data }) } catch(error) { diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyftDb/postgres_setup/create_tables.psql index 2e3a75d6c3..4135e5e41e 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyftDb/postgres_setup/create_tables.psql @@ -23,10 +23,12 @@ CREATE TABLE IF NOT EXISTS txs ( amount numeric, gasprice numeric, gas numeric, + gasLimit numeric, txFee numeric, nonce numeric, txStatus text, isContract bool, + age timestamp, data bytea ); diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go index d27502618e..20d1e6355f 100644 --- a/shyftdb/shyft_database_util.go +++ b/shyftdb/shyft_database_util.go @@ -78,10 +78,12 @@ type ShyftTxEntryPretty struct { Amount uint64 GasPrice uint64 Gas uint64 + GasLimit uint64 Cost uint64 Nonce uint64 Status string IsContract bool + Age time.Time Data []byte } @@ -100,13 +102,7 @@ type SendAndReceive struct { } //WriteBlock writes to block info to sql db - func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error { - //Need to create field in postgres db isContract : True || False - //Need to fix nonce numeric issue (attempt to reproduce and record) - //Need to update tx To Field where null with Contract Address - //Need to update account table with that Contract Address - //Need to update AccountNonce and Balance of Tx To field || Contract Address - +func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error { coinbase := block.Header().Coinbase.String() number := block.Header().Number.String() gasUsed := block.Header().GasUsed @@ -134,7 +130,7 @@ type SendAndReceive struct { if block.Transactions().Len() > 0 { for _, tx := range block.Transactions() { //WriteMinerRewards(sqldb, block) - WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts) + WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) if block.Transactions()[0].To() != nil { WriteFromBalance(sqldb, tx) } @@ -148,7 +144,7 @@ type SendAndReceive struct { } //WriteTransactions writes to sqldb -func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt) error { +func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error { txData := ShyftTxEntry{ TxHash: tx.Hash(), From: tx.From(), @@ -161,7 +157,8 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha Nonce: tx.Nonce(), Data: tx.Data(), } - + fmt.Println("THIS IS AGE", age) + fmt.Println("THIS IS GAS LIMIT", gasLimit) txHash := txData.TxHash.Hex() from := txData.From.Hex() blockHasher := txData.BlockHash @@ -190,8 +187,8 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha var retNonce string isContract = true - sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, txStatus, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13)) RETURNING nonce` - qerr := sqldb.QueryRow(sqlStatement, txHash, from, contractAddressFromReciept, blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, statusFromReciept, data).Scan(&retNonce) + sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, gasLimit,txfee, nonce, isContract, txStatus, age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce` + qerr := sqldb.QueryRow(sqlStatement, txHash, from, contractAddressFromReciept, blockHasher, blockNumber, amount, gasPrice, gas, gasLimit, txFee, nonce, isContract, statusFromReciept, age,data).Scan(&retNonce) if qerr != nil { panic(qerr) @@ -209,8 +206,8 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha } } - sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, txStatus, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13)) RETURNING nonce` - qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, statusFromReciept, data).Scan(&retNonce) + sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, gasLimit, txfee, nonce, isContract, txStatus, age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce` + qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, blockNumber, amount, gasPrice, gas, gasLimit, txFee, nonce, isContract, statusFromReciept, age,data).Scan(&retNonce) if qerr != nil { panic(qerr) @@ -612,10 +609,12 @@ func GetAllTransactions(sqldb *sql.DB) string { var amount uint64 var gasprice uint64 var gas uint64 + var gasLimit uint64 var txfee uint64 var nonce uint64 var status string var isContract bool + var age time.Time var data []byte err = rows.Scan( &txhash, @@ -626,10 +625,12 @@ func GetAllTransactions(sqldb *sql.DB) string { &amount, &gasprice, &gas, + &gasLimit, &txfee, &nonce, &status, &isContract, + &age, &data, ) @@ -642,10 +643,12 @@ func GetAllTransactions(sqldb *sql.DB) string { Amount: amount, GasPrice: gasprice, Gas: gas, + GasLimit: gasLimit, Cost: txfee, Nonce: nonce, Status: status, IsContract: isContract, + Age: age, Data: data, }) @@ -660,32 +663,39 @@ func GetAllTransactions(sqldb *sql.DB) string { 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 - var blockhash string - var blocknumber string - var amount uint64 - var gasprice uint64 - var gas uint64 - var txfee uint64 - var nonce uint64 - var status string - var isContract bool - var data []byte + var txhash string + var to_addr string + var from_addr string + var blockhash string + var blocknumber string + var amount uint64 + var gasprice uint64 + var gas uint64 + var gasLimit uint64 + var txfee uint64 + var nonce uint64 + var status string + var isContract bool + var age time.Time + var data []byte + row.Scan( &txhash, &to_addr, &from_addr, &blockhash, + &blocknumber, &amount, &gasprice, &gas, + &gasLimit, &txfee, &nonce, &status, &isContract, + &age, &data) + tx := ShyftTxEntryPretty{ TxHash: txhash, To: to_addr, @@ -695,10 +705,12 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { Amount: amount, GasPrice: gasprice, Gas: gas, + GasLimit: gasLimit, Cost: txfee, Nonce: nonce, Status: status, IsContract: isContract, + Age: age, Data: data, } json, _ := json.Marshal(tx) From 5804bd113fb835429a019b886cd01b26e3e3fac2 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 17 May 2018 10:36:55 -0400 Subject: [PATCH 4/5] cleaned up fmt --- shyftdb/shyft_database_util.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go index 20d1e6355f..6dee4a5834 100644 --- a/shyftdb/shyft_database_util.go +++ b/shyftdb/shyft_database_util.go @@ -157,8 +157,6 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha Nonce: tx.Nonce(), Data: tx.Data(), } - fmt.Println("THIS IS AGE", age) - fmt.Println("THIS IS GAS LIMIT", gasLimit) txHash := txData.TxHash.Hex() from := txData.From.Hex() blockHasher := txData.BlockHash @@ -678,7 +676,6 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { var isContract bool var age time.Time var data []byte - row.Scan( &txhash, &to_addr, From 1b5ee8a1f165787fbf6b52b60e976abc0b205fed Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 17 May 2018 11:09:52 -0400 Subject: [PATCH 5/5] cleaned up console logs --- .../src/components/table/transactions/transactionDetailsRow.js | 1 - .../src/components/table/transactions/transactionTable.js | 1 - shyftBlockExplorerUI/src/containers/App.js | 2 -- 3 files changed, 4 deletions(-) diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js index 1ce7db2ac8..889bb3e33f 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js @@ -5,7 +5,6 @@ class DetailTransactionTable extends Component { render() { let data = this.props.data - console.log(data) let combinedClasses = ['responsive-table', classes.table]; return (
TxHash Block Age From To Value TxFee
{props.blockNumber}30 secs ago{props.age} {props.from}{props.to}{props.to} {props.value} {props.cost}
diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js index 2d3210b60c..3f6c4d9fc2 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js @@ -4,7 +4,6 @@ import arrow from '../../assets/arrow_right.png'; import { Link } from 'react-router-dom' const TransactionTable = (props) => { - console.log(props) return ( diff --git a/shyftBlockExplorerUI/src/containers/App.js b/shyftBlockExplorerUI/src/containers/App.js index b794f9283f..6029f37e68 100644 --- a/shyftBlockExplorerUI/src/containers/App.js +++ b/shyftBlockExplorerUI/src/containers/App.js @@ -32,10 +32,8 @@ class App extends Component { } detailTransactionHandler = async(txHash) => { - console.log("THIS RAN") try { const response = await axios.get(`http://localhost:8080/api/get_transaction/${txHash}`) - console.log("THIS IS RESPONSE", response) await this.setState({ transactionDetailData: response.data }) } catch(error) {