diff --git a/cmd/dcrdata/internal/explorer/explorer.go b/cmd/dcrdata/internal/explorer/explorer.go index bfbbaf9e8..660338544 100644 --- a/cmd/dcrdata/internal/explorer/explorer.go +++ b/cmd/dcrdata/internal/explorer/explorer.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2022, The Decred developers +// Copyright (c) 2018-2024, The Decred developers // Copyright (c) 2017, The dcrdata developers // See LICENSE for details. @@ -366,7 +366,7 @@ func New(cfg *ExplorerConfig) *explorerUI { tmpls := []string{"home", "blocks", "mempool", "block", "tx", "address", "rawtx", "status", "parameters", "agenda", "agendas", "charts", - "sidechains", "disapproved", "ticketpool", "visualblocks", "statistics", + "sidechains", "disapproved", "ticketpool", "visualblocks", "windows", "timelisting", "addresstable", "proposals", "proposal", "market", "insight_root", "attackcost", "treasury", "treasurytable", "verify_message"} @@ -671,8 +671,6 @@ func (exp *explorerUI) addRoutes() { exp.Mux.Get("/address/{x}", redirect("address")) exp.Mux.Get("/decodetx", redirect("decodetx")) - - exp.Mux.Get("/stats", redirect("statistics")) } // Simulate ticket purchase and re-investment over a full year for a given diff --git a/cmd/dcrdata/internal/explorer/explorerroutes.go b/cmd/dcrdata/internal/explorer/explorerroutes.go index 2cf68169c..323601806 100644 --- a/cmd/dcrdata/internal/explorer/explorerroutes.go +++ b/cmd/dcrdata/internal/explorer/explorerroutes.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2022, The Decred developers +// Copyright (c) 2018-2024, The Decred developers // Copyright (c) 2017, The dcrdata developers // See LICENSE for details. @@ -2458,93 +2458,6 @@ func (exp *explorerUI) HandleApiRequestsOnSync(w http.ResponseWriter, r *http.Re io.WriteString(w, str) } -// StatsPage is the page handler for the "/stats" path. -func (exp *explorerUI) StatsPage(w http.ResponseWriter, r *http.Request) { - // Get current PoW difficulty. - powDiff, err := exp.dataSource.CurrentDifficulty() - if err != nil { - log.Errorf("Failed to get Difficulty: %v", err) - } - - // Subsidies - dcp0010Height := exp.dataSource.DCP0010ActivationHeight() - dcp0012Height := exp.dataSource.DCP0012ActivationHeight() - ultSubsidy := txhelpers.UltimateSubsidy(exp.ChainParams, dcp0010Height, dcp0012Height) - bestBlockHeight, err := exp.dataSource.GetHeight() - if err != nil { - log.Errorf("GetHeight failed: %v", err) - exp.StatusPage(w, defaultErrorCode, defaultErrorMessage, "", - ExpStatusError) - return - } - blockSubsidy := exp.dataSource.BlockSubsidy(bestBlockHeight, - exp.ChainParams.TicketsPerBlock) - - // Safely retrieve the inventory pointer, which can be reset in StoreMPData. - inv := exp.MempoolInventory() - - // Prevent modifications to the shared inventory struct (e.g. in the - // MempoolMonitor) while we retrieve the number of votes and tickets. - inv.RLock() - numVotes := inv.NumVotes - numTickets := inv.NumTickets - inv.RUnlock() - - exp.pageData.RLock() - stats := types.StatsInfo{ - TotalSupply: exp.pageData.HomeInfo.CoinSupply, - UltimateSupply: ultSubsidy, - TotalSupplyPercentage: float64(exp.pageData.HomeInfo.CoinSupply) / - float64(ultSubsidy) * 100, - ProjectFunds: exp.pageData.HomeInfo.DevFund, - ProjectAddress: exp.pageData.HomeInfo.DevAddress, - PoWDiff: exp.pageData.HomeInfo.Difficulty, - BlockReward: blockSubsidy.Total, - NextBlockReward: exp.pageData.HomeInfo.NBlockSubsidy.Total, - PoWReward: exp.pageData.HomeInfo.NBlockSubsidy.PoW, - PoSReward: exp.pageData.HomeInfo.NBlockSubsidy.PoS, - ProjectFundReward: exp.pageData.HomeInfo.NBlockSubsidy.Dev, - VotesInMempool: numVotes, - TicketsInMempool: numTickets, - TicketPrice: exp.pageData.HomeInfo.StakeDiff, - NextEstimatedTicketPrice: exp.pageData.HomeInfo.NextExpectedStakeDiff, - TicketPoolSize: exp.pageData.HomeInfo.PoolInfo.Size, - TicketPoolSizePerToTarget: float64(exp.pageData.HomeInfo.PoolInfo.Size) / - float64(exp.ChainParams.TicketPoolSize*exp.ChainParams.TicketsPerBlock) * 100, - TicketPoolValue: exp.pageData.HomeInfo.PoolInfo.Value, - TPVOfTotalSupplyPeecentage: exp.pageData.HomeInfo.PoolInfo.Percentage, - TicketsROI: exp.pageData.HomeInfo.TicketReward, - RewardPeriod: exp.pageData.HomeInfo.RewardPeriod, - ASR: exp.pageData.HomeInfo.ASR, - APR: exp.pageData.HomeInfo.ASR, - IdxBlockInWindow: exp.pageData.HomeInfo.IdxBlockInWindow, - WindowSize: exp.pageData.HomeInfo.Params.WindowSize, - BlockTime: exp.pageData.HomeInfo.Params.BlockTime, - IdxInRewardWindow: exp.pageData.HomeInfo.IdxInRewardWindow, - RewardWindowSize: exp.pageData.HomeInfo.Params.RewardWindowSize, - HashRate: powDiff * math.Pow(2, 32) / - exp.ChainParams.TargetTimePerBlock.Seconds() / math.Pow(10, 15), - } - exp.pageData.RUnlock() - - str, err := exp.templates.exec("statistics", struct { - *CommonPageData - Stats types.StatsInfo - }{ - CommonPageData: exp.commonData(r), - Stats: stats, - }) - - if err != nil { - log.Errorf("Template execute failure: %v", err) - exp.StatusPage(w, defaultErrorCode, defaultErrorMessage, "", ExpStatusError) - return - } - w.Header().Set("Content-Type", "text/html") - w.WriteHeader(http.StatusOK) - io.WriteString(w, str) -} - // MarketPage is the page handler for the "/market" path. func (exp *explorerUI) MarketPage(w http.ResponseWriter, r *http.Request) { str, err := exp.templates.exec("market", struct { diff --git a/cmd/dcrdata/main.go b/cmd/dcrdata/main.go index bfc68f06a..ca925862d 100644 --- a/cmd/dcrdata/main.go +++ b/cmd/dcrdata/main.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2022, The Decred developers +// Copyright (c) 2018-2024, The Decred developers // Copyright (c) 2017, Jonathan Chappelow // See LICENSE for details. @@ -779,10 +779,9 @@ func _main(ctx context.Context) error { r.Get("/search", explore.Search) r.Get("/charts", explore.Charts) r.Get("/ticketpool", explore.Ticketpool) - r.Get("/stats", explore.StatsPage) r.Get("/market", explore.MarketPage) - r.Get("/statistics", func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, "/stats", http.StatusPermanentRedirect) + r.Get("/stats", func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/", http.StatusPermanentRedirect) }) // MenuFormParser will typically redirect, but going to the homepage as a // fallback. diff --git a/cmd/dcrdata/public/scss/application.scss b/cmd/dcrdata/public/scss/application.scss index 4dd978d99..cac11d2c6 100644 --- a/cmd/dcrdata/public/scss/application.scss +++ b/cmd/dcrdata/public/scss/application.scss @@ -42,7 +42,6 @@ @import "./table"; @import "./keyboard_navigation"; @import "./connection"; -@import "./stats_page"; @import "./animation"; @import "./voting"; @import "./transaction"; diff --git a/cmd/dcrdata/public/scss/stats_page.scss b/cmd/dcrdata/public/scss/stats_page.scss deleted file mode 100644 index b8393d853..000000000 --- a/cmd/dcrdata/public/scss/stats_page.scss +++ /dev/null @@ -1,115 +0,0 @@ -/* Stats Page */ -.card { - background-color: #fff; - box-shadow: 0 4px 8px 0 #e6eaed; - width: 250px; - height: 220px; - margin: auto; - margin-bottom: 20px; - margin-left: 20px; - float: left; - padding-bottom: 10px; - border-radius: 10px; - transition: all 0.2s ease-in-out; -} - -.card :hover { - overflow: hidden; - white-space: normal; -} - -.card-header { - text-transform: uppercase; - background-color: #e6eaed; - color: #8997a5; - text-align: center; - font-style: bold; - font-size: 16px; -} - -.card-body { - background-color: #fff; - color: #3d5873; - text-align: center; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.stat-headers { - color: #3d5873; - text-align: center; - font-size: 30px; -} - -.stat-link { - color: #2970ff; - font-size: 14px; -} - -.stat-data { - font-style: bold; - color: #3d5873; - margin: auto; - font-size: 25px; -} - -.decimal { - margin-left: -2px; - margin-right: 0; -} - -.no-decimal .dot { - display: none; -} - -.no-decimal .decimal { - display: none; -} - -.stat-details { - color: #96a0a9; - font-size: 14px; -} - -.card-body-padding-top { - padding-top: 2.3em; -} - -.block-rewards { - background-color: #a1c6e7; -} - -.proof-of-stake { - background-color: #e7c1a1; -} - -.network-statistics { - background-color: #a1e7d9; -} - -@media screen and (max-width: 1200px) { - .stat-headers { - margin-left: -146px; - } -} - -@media screen and (max-width: 926px) { - .stat-headers { - margin-left: -25px; - } - - #proof-stake-header { - margin-left: 0; - } -} - -@media screen and (max-width: 570px) { - .stat-headers { - margin-left: 0; - } - - #proof-stake-header { - margin-left: 38px; - } -} diff --git a/cmd/dcrdata/views/extras.tmpl b/cmd/dcrdata/views/extras.tmpl index b18893172..de7de93da 100644 --- a/cmd/dcrdata/views/extras.tmpl +++ b/cmd/dcrdata/views/extras.tmpl @@ -67,7 +67,7 @@ - + diff --git a/cmd/dcrdata/views/statistics.tmpl b/cmd/dcrdata/views/statistics.tmpl deleted file mode 100644 index a9027be50..000000000 --- a/cmd/dcrdata/views/statistics.tmpl +++ /dev/null @@ -1,224 +0,0 @@ -{{define "statistics"}} - - - {{ template "html-head" headData .CommonPageData "Decred Statistics"}} - {{ template "navbar" . }} - {{with .Stats}} -