diff --git a/blockExplorerApi/handler.go b/blockExplorerApi/handler.go index 3ba6e5d672..a030a6b07a 100644 --- a/blockExplorerApi/handler.go +++ b/blockExplorerApi/handler.go @@ -57,6 +57,30 @@ func GetAllTransactions(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, txs) } +// GetAllTransactions gets txs +func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + blockNumber := vars["blockNumber"] + connStr := "user=postgres dbname=shyftdb sslmode=disable" + blockExplorerDb, err := sql.Open("postgres", connStr) + if err != nil { + return + } + + txsFromBlock := shyftdb.GetAllTransactionsFromBlock(blockExplorerDb, blockNumber) + + if err != nil { + http.Error(w, err.Error(), 500) + return + } + + + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + + fmt.Fprintln(w, txsFromBlock) +} + // GetAccount gets balance func GetAccount(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) @@ -161,15 +185,22 @@ func GetAllBlocks(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, block3) } -//func GetRecentBlock(w http.ResponseWriter, r *http.Request) { -// connStr := "user=postgres dbname=shyftdb sslmode=disable" -// blockExplorerDb, err := sql.Open("postgres", connStr) -// if err != nil { -// return -// } -// -// -//} +func GetRecentBlock(w http.ResponseWriter, r *http.Request) { + connStr := "user=postgres dbname=shyftdb sslmode=disable" + blockExplorerDb, err := sql.Open("postgres", connStr) + if err != nil { + return + } + mostRecentBlock := shyftdb.GetRecentBlock(blockExplorerDb) + if err != nil { + http.Error(w, err.Error(), 500) + return + } + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, mostRecentBlock) + +} //GetInternalTransactions gets internal txs func GetInternalTransactions(w http.ResponseWriter, r *http.Request) { diff --git a/blockExplorerApi/routes.go b/blockExplorerApi/routes.go index 578efc3a23..a08e207f6e 100644 --- a/blockExplorerApi/routes.go +++ b/blockExplorerApi/routes.go @@ -57,12 +57,18 @@ var routes = Routes{ "/api/get_transaction/{txHash}", GetTransaction, }, - //Route{ - // Name: "GetRecentBlock", - // Method: "GET", - // Pattern: "/api/get_recent_block", - // HandlerFunc: GetRecentBlock, - //}, + Route{ + Name: "GetRecentBlock", + Method: "GET", + Pattern: "/api/get_recent_block", + HandlerFunc: GetRecentBlock, + }, + Route{ + Name: "GetAllTransactionsFromBlock", + Method: "GET", + Pattern: "/api/get_all_transactions_from_block/{blockNumber}", + HandlerFunc: GetAllTransactionsFromBlock, + }, Route{ "GetInternalTransactions", "GET", diff --git a/core/genesis.go b/core/genesis.go index b7aac23d53..1e39bfa094 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -249,7 +249,6 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis, sqldb *sql.DB) (*par if genesis != nil && genesis.Config == nil { return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig } - // Just commit the new block if there is no stored genesis block. stored := GetCanonicalHash(db, 0) if (stored == common.Hash{}) { diff --git a/shyftBlockExplorerUI/src/components/table/transactions/table.css b/shyftBlockExplorerUI/src/components/table/transactions/table.css index 38f3d87fed..7b1f0858f0 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/table.css +++ b/shyftBlockExplorerUI/src/components/table/transactions/table.css @@ -57,4 +57,9 @@ th { width: 25px; height: 25px; margin-left: 15px; +} + +.disabled { + pointer-events: none; + color: black; } \ No newline at end of file diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js index d978a82ed5..a4b399efc5 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js @@ -4,11 +4,18 @@ import arrow from '../../assets/arrow_right.png'; import { Link } from 'react-router-dom' const TransactionTable = (props) => { + let flag; + if(props.txHash.indexOf("GENESIS") != -1) { + flag = false + }else { + flag = true + } + return (