From 881eb4ff0f790be4a342172ab6f804366055a944 Mon Sep 17 00:00:00 2001 From: Alec Savvy Date: Wed, 2 Oct 2024 10:47:28 -0600 Subject: [PATCH 1/3] run --- core/console/console.go | 13 +++- core/console/state.go | 95 +++++++++++++++++++++++++++ core/core_pkg/run.go | 7 +- core/infra/dev_config/sandbox-one.env | 3 +- 4 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 core/console/state.go diff --git a/core/console/console.go b/core/console/console.go index 1918051bc2a..d609f822946 100644 --- a/core/console/console.go +++ b/core/console/console.go @@ -22,17 +22,24 @@ type Console struct { e *echo.Echo logger *common.Logger + state *State layouts *layout.Layout views *views.Views } func NewConsole(config *config.Config, logger *common.Logger, e *echo.Echo, rpc client.Client, pool *pgxpool.Pool) (*Console, error) { + db := db.New(pool) + state, err := NewState(config, rpc, logger, db) + if err != nil { + return nil, err + } c := &Console{ config: config, rpc: rpc, e: e, logger: logger.Child(strings.TrimPrefix(baseURL, "/")), - db: db.New(pool), + db: db, + state: state, views: views.NewViews(config, baseURL), layouts: layout.NewLayout(config, baseURL), } @@ -41,3 +48,7 @@ func NewConsole(config *config.Config, logger *common.Logger, e *echo.Echo, rpc return c, nil } + +func (c *Console) Start() error { + return c.state.Start() +} diff --git a/core/console/state.go b/core/console/state.go new file mode 100644 index 00000000000..9292e72a7a8 --- /dev/null +++ b/core/console/state.go @@ -0,0 +1,95 @@ +package console + +import ( + "context" + "fmt" + + "github.com/AudiusProject/audius-protocol/core/common" + "github.com/AudiusProject/audius-protocol/core/config" + "github.com/AudiusProject/audius-protocol/core/db" + v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1" + "github.com/cometbft/cometbft/rpc/client" + coretypes "github.com/cometbft/cometbft/rpc/core/types" + "github.com/cometbft/cometbft/types" +) + +type State struct { + rpc client.Client + logger *common.Logger + db *db.Queries + + newBlockChan <-chan coretypes.ResultEvent + newTxChan <-chan coretypes.ResultEvent + latestBlocks []*types.Block + latestTransactions []*v1.ExecTxResult + + totalBlocks int64 + totalTransactions int64 + isCatchingUp bool + + chainId string + ethAddress string + cometAddress string +} + +func NewState(config *config.Config, rpc client.Client, logger *common.Logger, db *db.Queries) (*State, error) { + newBlocksChan, err := rpc.Subscribe(context.Background(), "new-block-subscriber", types.EventQueryNewBlock.String()) + if err != nil { + return nil, fmt.Errorf("could not create block subscriber: %v", err) + } + + newTxsChan, err := rpc.Subscribe(context.Background(), "new-tx-subscriber", types.EventQueryTx.String()) + if err != nil { + return nil, fmt.Errorf("could not create transaction subscriber: %v", err) + } + + return &State{ + rpc: rpc, + logger: logger, + db: db, + + newBlockChan: newBlocksChan, + newTxChan: newTxsChan, + latestBlocks: []*types.Block{}, + latestTransactions: []*v1.ExecTxResult{}, + chainId: config.GenesisFile.ChainID, + ethAddress: config.WalletAddress, + cometAddress: config.ProposerAddress, + }, nil +} + +func (state *State) Start() error { + logger := state.logger + for { + newBlock := false + newTx := false + + select { + case newBlockEvent := <-state.newBlockChan: + blockEvent, ok := newBlockEvent.Data.(types.EventDataNewBlock) + if ok { + newBlock = true + block := blockEvent.Block + state.latestBlocks = append(state.latestBlocks, block) + if len(state.latestBlocks) > 10 { + state.latestBlocks = state.latestBlocks[len(state.latestBlocks)-10:] + } + } + case newTxEvent := <-state.newTxChan: + txEvent, ok := newTxEvent.Data.(types.EventDataTx) + if ok { + newTx = true + txResult := txEvent.GetResult() + state.latestTransactions = append(state.latestTransactions, &txResult) + if len(state.latestTransactions) > 10 { + state.latestTransactions = state.latestTransactions[len(state.latestTransactions)-10:] + } + } + } + + newEvent := newBlock || newTx + if newEvent { + logger.Infof("total things %v %v", len(state.latestBlocks), len(state.latestTransactions)) + } + } +} diff --git a/core/core_pkg/run.go b/core/core_pkg/run.go index 9b1d359f5d8..decc56fcee2 100644 --- a/core/core_pkg/run.go +++ b/core/core_pkg/run.go @@ -103,7 +103,7 @@ func run(ctx context.Context, logger *common.Logger) error { return fmt.Errorf("server init error: %v", err) } - _, err = console.NewConsole(config, logger, e, rpc, pool) + con, err := console.NewConsole(config, logger, e, rpc, pool) if err != nil { return fmt.Errorf("console init error: %v", err) } @@ -156,6 +156,11 @@ func run(ctx context.Context, logger *common.Logger) error { return registryBridge.Start() }) + eg.Go(func() error { + logger.Info("core Console starting") + return con.Start() + }) + // Wait for all services to finish or for context cancellation return eg.Wait() } diff --git a/core/infra/dev_config/sandbox-one.env b/core/infra/dev_config/sandbox-one.env index 7579c36010d..c2729168dc6 100644 --- a/core/infra/dev_config/sandbox-one.env +++ b/core/infra/dev_config/sandbox-one.env @@ -1,8 +1,7 @@ audius_core_root_dir=./tmp/sandboxOneHome audius_delegate_private_key=d09ba371c359f10f22ccda12fd26c598c7921bda3220c9942174562bc6a36fe8 -audius_discprov_env=sandbox +audius_discprov_env=stage audius_db_url=postgres://postgres:postgres@sandbox-core-db:5432/core_db?sslmode=disable audius_discprov_url=http://0.0.0.0:6612 -runDownMigration="true" p2pLaddr="tcp://0.0.0.0:26656" rpcLaddr="tcp://0.0.0.0:26657" From ee961bffe7b4443ba68c7bb0d884d143d238d7cf Mon Sep 17 00:00:00 2001 From: Alec Savvy Date: Wed, 2 Oct 2024 12:03:46 -0600 Subject: [PATCH 2/3] self updating nav state --- core/console/nav.go | 13 ++++ core/console/routes.go | 3 +- core/console/state.go | 22 +++++++ core/console/views/layout/site_frame.templ | 3 + core/console/views/layout/site_frame_templ.go | 4 +- core/console/views/pages/nav_block_data.templ | 6 ++ .../views/pages/nav_block_data_templ.go | 66 +++++++++++++++++++ core/console/views/views.go | 4 ++ core/infra/dev_config/sandbox-one.env | 1 + 9 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 core/console/nav.go create mode 100644 core/console/views/pages/nav_block_data.templ create mode 100644 core/console/views/pages/nav_block_data_templ.go diff --git a/core/console/nav.go b/core/console/nav.go new file mode 100644 index 00000000000..ecbe78cda23 --- /dev/null +++ b/core/console/nav.go @@ -0,0 +1,13 @@ +package console + +import ( + "fmt" + + "github.com/labstack/echo/v4" +) + +func (con *Console) navChainData(c echo.Context) error { + totalBlocks := fmt.Sprint(con.state.totalBlocks) + totalTxs := fmt.Sprint(con.state.totalTransactions) + return con.views.RenderNavChainData(c, totalBlocks, totalTxs) +} diff --git a/core/console/routes.go b/core/console/routes.go index f105d26e2db..c3444faecd5 100644 --- a/core/console/routes.go +++ b/core/console/routes.go @@ -30,7 +30,6 @@ func (c *Console) registerRoutes(logger *common.Logger, e *echo.Echo) { g.StaticFS("/*", embeddedAssets) - // htmx fragments that make up pages derived from routes g.GET("/overview", c.overviewPage) g.GET("/analytics", c.analyticsPage) g.GET("/nodes", c.nodesPage) @@ -42,6 +41,8 @@ func (c *Console) registerRoutes(logger *common.Logger, e *echo.Echo) { g.GET("/tx/:tx", c.txPage) g.GET("/genesis", c.genesisPage) + g.GET("/fragments/nav/chain_data", c.navChainData) + // future pages // g.GET("/blocks", c.blocksPage) // g.GET("/txs", c.txsPage) diff --git a/core/console/state.go b/core/console/state.go index 9292e72a7a8..cc65bb0261e 100644 --- a/core/console/state.go +++ b/core/console/state.go @@ -89,7 +89,29 @@ func (state *State) Start() error { newEvent := newBlock || newTx if newEvent { + ctx := context.Background() logger.Infof("total things %v %v", len(state.latestBlocks), len(state.latestTransactions)) + + totalTxs, err := state.db.TotalTransactions(ctx) + if err != nil { + logger.Errorf("could not get total txs: %v", err) + } else { + state.totalTransactions = totalTxs + } + + totalBlocks, err := state.db.TotalBlocks(ctx) + if err != nil { + logger.Errorf("could not get total blocks: %v", err) + } else { + state.totalBlocks = totalBlocks + } + + status, err := state.rpc.Status(ctx) + if err != nil { + logger.Errorf("could not get node status: %v", err) + } else { + state.isCatchingUp = status.SyncInfo.CatchingUp + } } } } diff --git a/core/console/views/layout/site_frame.templ b/core/console/views/layout/site_frame.templ index e47a8c74a98..3921e363dd4 100644 --- a/core/console/views/layout/site_frame.templ +++ b/core/console/views/layout/site_frame.templ @@ -45,6 +45,9 @@ templ (l *Layout) SiteFrame() { } +
+ block data +
diff --git a/core/console/views/layout/site_frame_templ.go b/core/console/views/layout/site_frame_templ.go index e224debc2d8..d661f482f84 100644 --- a/core/console/views/layout/site_frame_templ.go +++ b/core/console/views/layout/site_frame_templ.go @@ -179,7 +179,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
block data
  • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -333,7 +333,7 @@ func (l *Layout) SiteFrame() templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(config.Version) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 89, Col: 74} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 92, Col: 74} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { diff --git a/core/console/views/pages/nav_block_data.templ b/core/console/views/pages/nav_block_data.templ new file mode 100644 index 00000000000..dfe4159d9f9 --- /dev/null +++ b/core/console/views/pages/nav_block_data.templ @@ -0,0 +1,6 @@ +package pages + +templ (p *Pages) NavBlockData(totalBlocks, totalTxs string) { +
    Total Blocks: { totalBlocks }
    +
    Total Transactions: { totalTxs }
    +} diff --git a/core/console/views/pages/nav_block_data_templ.go b/core/console/views/pages/nav_block_data_templ.go new file mode 100644 index 00000000000..782c80563e1 --- /dev/null +++ b/core/console/views/pages/nav_block_data_templ.go @@ -0,0 +1,66 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.778 +package pages + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +func (p *Pages) NavBlockData(totalBlocks, totalTxs string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Total Blocks: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(totalBlocks) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/nav_block_data.templ`, Line: 4, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Total Transactions: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(totalTxs) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/nav_block_data.templ`, Line: 5, Col: 36} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/core/console/views/views.go b/core/console/views/views.go index 934761dbc58..111da233faa 100644 --- a/core/console/views/views.go +++ b/core/console/views/views.go @@ -16,6 +16,10 @@ func NewViews(config *config.Config, baseUrl string) *Views { } } +func (v *Views) RenderNavChainData(c echo.Context, totalBlocks, totalTxs string) error { + return v.pages.NavBlockData(totalBlocks, totalTxs).Render(c.Request().Context(), c.Response().Writer) +} + func (v *Views) RenderOverviewView(c echo.Context, data *pages.OverviewPageView) error { return v.pages.OverviewPageHTML(data).Render(c.Request().Context(), c.Response().Writer) } diff --git a/core/infra/dev_config/sandbox-one.env b/core/infra/dev_config/sandbox-one.env index c2729168dc6..77e9e19d408 100644 --- a/core/infra/dev_config/sandbox-one.env +++ b/core/infra/dev_config/sandbox-one.env @@ -3,5 +3,6 @@ audius_delegate_private_key=d09ba371c359f10f22ccda12fd26c598c7921bda3220c9942174 audius_discprov_env=stage audius_db_url=postgres://postgres:postgres@sandbox-core-db:5432/core_db?sslmode=disable audius_discprov_url=http://0.0.0.0:6612 +runDownMigration="true" p2pLaddr="tcp://0.0.0.0:26656" rpcLaddr="tcp://0.0.0.0:26657" From 0fdebcb77a3bb4f455cd2677e2ce3ea0811df85c Mon Sep 17 00:00:00 2001 From: Alec Savvy Date: Wed, 2 Oct 2024 13:11:22 -0600 Subject: [PATCH 3/3] recent blocks --- core/console/analytics.go | 9 + core/console/overview.go | 33 +-- core/console/routes.go | 1 + core/console/state.go | 161 ++++++++----- core/console/views/layout/site_frame.templ | 5 + core/console/views/layout/site_frame_templ.go | 139 +++++++---- core/console/views/pages/analytics_page.templ | 60 +++-- .../views/pages/analytics_page_templ.go | 154 ++++++++----- core/console/views/pages/nav_block_data.templ | 6 - .../views/pages/nav_block_data_templ.go | 66 ------ core/console/views/pages/overview_page.templ | 48 ++-- .../views/pages/overview_page_templ.go | 216 +++++++++--------- core/console/views/views.go | 13 +- core/go.mod | 2 +- core/grpc/constants.go | 8 +- 15 files changed, 507 insertions(+), 414 deletions(-) delete mode 100644 core/console/views/pages/nav_block_data.templ delete mode 100644 core/console/views/pages/nav_block_data_templ.go diff --git a/core/console/analytics.go b/core/console/analytics.go index 9c669baa3b4..6af353ac827 100644 --- a/core/console/analytics.go +++ b/core/console/analytics.go @@ -56,3 +56,12 @@ func (con *Console) analyticsPage(c echo.Context) error { } return con.views.RenderAnalyticsView(c, data) } + +func (con *Console) analyticsHeader(c echo.Context) error { + totalBlocks := fmt.Sprint(con.state.totalBlocks) + totalTransactions := fmt.Sprint(con.state.totalTransactions) + totalPlays := fmt.Sprint(con.state.totalPlays) + totalManageEntities := fmt.Sprint(con.state.totalManageEntities) + totalValidators := fmt.Sprint(con.state.totalValidators) + return con.views.RenderAnalyticsHeader(c, totalBlocks, totalTransactions, totalPlays, totalManageEntities, totalValidators) +} diff --git a/core/console/overview.go b/core/console/overview.go index 9fe6f342631..9195aa6f548 100644 --- a/core/console/overview.go +++ b/core/console/overview.go @@ -1,43 +1,14 @@ package console import ( - "encoding/hex" - "fmt" - "github.com/AudiusProject/audius-protocol/core/console/views/pages" - coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/labstack/echo/v4" ) func (cs *Console) overviewPage(c echo.Context) error { - ctx := c.Request().Context() - - block, err := cs.rpc.Block(ctx, nil) - if err != nil { - return err - } - - if block == nil { - // default to null block - block = &coretypes.ResultBlock{} - } - - recentTxs, err := cs.db.GetRecentTxs(ctx) - if err != nil { - return err - } - - blockData := pages.BlockView{ - Height: fmt.Sprint(block.Block.Height), - Hash: hex.EncodeToString(block.Block.Hash()), - Proposer: block.Block.Header.ProposerAddress.String(), - Timestamp: block.Block.Time, - Txs: block.Block.Txs.ToSliceOfBytes(), - } - view := &pages.OverviewPageView{ - Block: blockData, - Txs: recentTxs, + Blocks: cs.state.latestBlocks, + Txs: cs.state.latestTransactions, } return cs.views.RenderOverviewView(c, view) diff --git a/core/console/routes.go b/core/console/routes.go index c3444faecd5..d4e6947aea3 100644 --- a/core/console/routes.go +++ b/core/console/routes.go @@ -42,6 +42,7 @@ func (c *Console) registerRoutes(logger *common.Logger, e *echo.Echo) { g.GET("/genesis", c.genesisPage) g.GET("/fragments/nav/chain_data", c.navChainData) + g.GET("/fragments/analytics/header", c.analyticsHeader) // future pages // g.GET("/blocks", c.blocksPage) diff --git a/core/console/state.go b/core/console/state.go index cc65bb0261e..27f439de749 100644 --- a/core/console/state.go +++ b/core/console/state.go @@ -2,12 +2,14 @@ package console import ( "context" + "encoding/hex" "fmt" "github.com/AudiusProject/audius-protocol/core/common" "github.com/AudiusProject/audius-protocol/core/config" + "github.com/AudiusProject/audius-protocol/core/console/views/pages" "github.com/AudiusProject/audius-protocol/core/db" - v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1" + "github.com/AudiusProject/audius-protocol/core/grpc" "github.com/cometbft/cometbft/rpc/client" coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/types" @@ -20,12 +22,14 @@ type State struct { newBlockChan <-chan coretypes.ResultEvent newTxChan <-chan coretypes.ResultEvent - latestBlocks []*types.Block - latestTransactions []*v1.ExecTxResult + latestBlocks []pages.BlockView + latestTransactions []db.CoreTxResult - totalBlocks int64 - totalTransactions int64 - isCatchingUp bool + totalBlocks int64 + totalTransactions int64 + totalPlays int64 + totalValidators int64 + totalManageEntities int64 chainId string ethAddress string @@ -48,70 +52,113 @@ func NewState(config *config.Config, rpc client.Client, logger *common.Logger, d logger: logger, db: db, - newBlockChan: newBlocksChan, - newTxChan: newTxsChan, - latestBlocks: []*types.Block{}, - latestTransactions: []*v1.ExecTxResult{}, - chainId: config.GenesisFile.ChainID, - ethAddress: config.WalletAddress, - cometAddress: config.ProposerAddress, + newBlockChan: newBlocksChan, + newTxChan: newTxsChan, + chainId: config.GenesisFile.ChainID, + ethAddress: config.WalletAddress, + cometAddress: config.ProposerAddress, }, nil } -func (state *State) Start() error { +func (state *State) recalculateState() { + ctx := context.Background() logger := state.logger + + state.latestTenBlocks() + + recentTransactions, err := state.db.GetRecentTxs(ctx) + if err != nil { + logger.Errorf("could not get recent txs: %v", err) + } else { + state.latestTransactions = recentTransactions + } + + // on initial load + totalTxs, err := state.db.TotalTransactions(ctx) + if err != nil { + logger.Errorf("could not get total txs: %v", err) + } else { + state.totalTransactions = totalTxs + } + + totalBlocks, err := state.db.TotalBlocks(ctx) + if err != nil { + logger.Errorf("could not get total blocks: %v", err) + } else { + state.totalBlocks = totalBlocks + } + + totalPlays, err := state.db.TotalTransactionsByType(ctx, grpc.TrackPlaysProtoName) + if err != nil { + logger.Errorf("could not get total plays: %v", err) + } else { + state.totalPlays = totalPlays + } + + totalManageEntities, err := state.db.TotalTransactionsByType(ctx, grpc.ManageEntitiesProtoName) + if err != nil { + logger.Errorf("could not get total manage entities: %v", err) + } else { + state.totalManageEntities = totalManageEntities + } + + totalValidators, err := state.db.TotalValidators(ctx) + if err != nil { + logger.Errorf("could not get total validators: %v", err) + } else { + state.totalValidators = totalValidators + } +} + +func (state *State) latestTenBlocks() { + client := state.rpc + status, err := client.Status(context.Background()) + if err != nil { + state.logger.Errorf("failed to get status: %v", err) + } + + latestHeight := status.SyncInfo.LatestBlockHeight + fmt.Printf("Latest Block Height: %d\n", latestHeight) + + latestBlocks := []pages.BlockView{} + + // Fetch the last 10 blocks + for height := latestHeight; height > latestHeight-10 && height > 0; height-- { + blockResult, err := client.Block(context.Background(), &height) + if err != nil { + state.logger.Errorf("failed to get block at height %d: %v", height, err) + } + + block := blockResult.Block + latestBlocks = append(latestBlocks, pages.BlockView{ + Height: fmt.Sprint(block.Height), + Hash: hex.EncodeToString(block.Hash()), + Proposer: block.Header.ProposerAddress.String(), + Timestamp: block.Time, + Txs: block.Txs.ToSliceOfBytes(), + }) + } + + state.latestBlocks = latestBlocks +} + +func (state *State) Start() error { + state.recalculateState() + for { newBlock := false newTx := false select { - case newBlockEvent := <-state.newBlockChan: - blockEvent, ok := newBlockEvent.Data.(types.EventDataNewBlock) - if ok { - newBlock = true - block := blockEvent.Block - state.latestBlocks = append(state.latestBlocks, block) - if len(state.latestBlocks) > 10 { - state.latestBlocks = state.latestBlocks[len(state.latestBlocks)-10:] - } - } - case newTxEvent := <-state.newTxChan: - txEvent, ok := newTxEvent.Data.(types.EventDataTx) - if ok { - newTx = true - txResult := txEvent.GetResult() - state.latestTransactions = append(state.latestTransactions, &txResult) - if len(state.latestTransactions) > 10 { - state.latestTransactions = state.latestTransactions[len(state.latestTransactions)-10:] - } - } + case <-state.newBlockChan: + newBlock = true + case <-state.newTxChan: + newTx = true } newEvent := newBlock || newTx if newEvent { - ctx := context.Background() - logger.Infof("total things %v %v", len(state.latestBlocks), len(state.latestTransactions)) - - totalTxs, err := state.db.TotalTransactions(ctx) - if err != nil { - logger.Errorf("could not get total txs: %v", err) - } else { - state.totalTransactions = totalTxs - } - - totalBlocks, err := state.db.TotalBlocks(ctx) - if err != nil { - logger.Errorf("could not get total blocks: %v", err) - } else { - state.totalBlocks = totalBlocks - } - - status, err := state.rpc.Status(ctx) - if err != nil { - logger.Errorf("could not get node status: %v", err) - } else { - state.isCatchingUp = status.SyncInfo.CatchingUp - } + state.recalculateState() } } } diff --git a/core/console/views/layout/site_frame.templ b/core/console/views/layout/site_frame.templ index 3921e363dd4..e76109806e7 100644 --- a/core/console/views/layout/site_frame.templ +++ b/core/console/views/layout/site_frame.templ @@ -8,6 +8,11 @@ import ( var gitCommit = templ.URL(fmt.Sprintf("https://github.com/AudiusProject/audius-protocol/commits/%s", config.Version)) +templ (l *Layout) NavBlockData(totalBlocks, totalTxs string) { +
    Total Blocks: { totalBlocks }
    +
    Total Transactions: { totalTxs }
    +} + templ (l *Layout) SiteFrame() { @l.Base() {
    diff --git a/core/console/views/layout/site_frame_templ.go b/core/console/views/layout/site_frame_templ.go index d661f482f84..70b8649fb01 100644 --- a/core/console/views/layout/site_frame_templ.go +++ b/core/console/views/layout/site_frame_templ.go @@ -16,7 +16,7 @@ import ( var gitCommit = templ.URL(fmt.Sprintf("https://github.com/AudiusProject/audius-protocol/commits/%s", config.Version)) -func (l *Layout) SiteFrame() templ.Component { +func (l *Layout) NavBlockData(totalBlocks, totalTxs string) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -37,7 +37,62 @@ func (l *Layout) SiteFrame() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Total Blocks: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(totalBlocks) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 12, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Total Transactions: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(totalTxs) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 13, Col: 36} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func (l *Layout) SiteFrame() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -53,12 +108,12 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var3 string - templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(assets.AudiusLogoBlackGlyph) + var templ_7745c5c3_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(assets.AudiusLogoBlackGlyph) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 18, Col: 45} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 23, Col: 45} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -66,7 +121,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -82,12 +137,12 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var5 string - templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(l.config.GenesisFile.ChainID) + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(l.config.GenesisFile.ChainID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 28, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 33, Col: 46} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -97,7 +152,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/genesis").Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/genesis").Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -105,7 +160,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -121,12 +176,12 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(l.config.WalletAddress) + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(l.config.WalletAddress) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 36, Col: 40} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 41, Col: 40} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -136,7 +191,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/node/%s", l.config.WalletAddress).Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/node/%s", l.config.WalletAddress).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -144,7 +199,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var8 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var11 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -160,12 +215,12 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(l.config.ProposerAddress) + var templ_7745c5c3_Var12 string + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(l.config.ProposerAddress) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 44, Col: 42} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 49, Col: 42} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -175,7 +230,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/node/%s", l.config.ProposerAddress).Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/node/%s", l.config.ProposerAddress).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -183,7 +238,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var10 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -201,7 +256,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/overview").Render(templ.WithChildren(ctx, templ_7745c5c3_Var10), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/overview").Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -209,7 +264,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var11 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var14 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -227,7 +282,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/analytics").Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/analytics").Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -235,7 +290,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var15 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -253,7 +308,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/nodes").Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/nodes").Render(templ.WithChildren(ctx, templ_7745c5c3_Var15), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -261,7 +316,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var16 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -279,7 +334,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/content").Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/content").Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -287,7 +342,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var14 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var17 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -305,7 +360,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.components.Link("/uptime").Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.components.Link("/uptime").Render(templ.WithChildren(ctx, templ_7745c5c3_Var17), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -313,7 +368,7 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var4.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -321,8 +376,8 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var15 templ.SafeURL = gitCommit - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var15))) + var templ_7745c5c3_Var18 templ.SafeURL = gitCommit + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var18))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -330,12 +385,12 @@ func (l *Layout) SiteFrame() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(config.Version) + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(config.Version) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 92, Col: 74} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/layout/site_frame.templ`, Line: 97, Col: 74} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -345,7 +400,7 @@ func (l *Layout) SiteFrame() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = l.Base().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = l.Base().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/core/console/views/pages/analytics_page.templ b/core/console/views/pages/analytics_page.templ index 06a0ab8e1ae..11174b32e90 100644 --- a/core/console/views/pages/analytics_page.templ +++ b/core/console/views/pages/analytics_page.templ @@ -24,35 +24,47 @@ templ (p *Pages) loadChart() { } -templ (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) { - @p.layout.SiteFrame() { -
    -
    -
    -
    -

    Total Blocks

    -

    { data.TotalBlocks }

    -
    +templ (p *Pages) AnalyticsHeaderHTML(TotalBlocks, TotalTransactions, TotalPlays, TotalManageEntities, TotalValidators string) { +
    +
    +
    +
    +

    Total Blocks

    +

    { TotalBlocks }

    -
    -
    -

    Total Transactions

    -

    { data.TotalTransactions }

    -
    +
    +
    +
    +

    Total Transactions

    +

    { TotalTransactions }

    -
    -
    -

    Total Plays

    -

    { data.TotalPlays }

    -
    +
    +
    +
    +

    Total Plays

    +

    { TotalPlays }

    +
    +
    +
    +
    +

    Total Manage Entities

    +

    { TotalManageEntities }

    -
    -
    -

    Validators

    -

    { data.TotalValidators }

    -
    +
    +
    +
    +

    Validators

    +

    { TotalValidators }

    +
    +
    +} + +templ (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) { + @p.layout.SiteFrame() { +
    +

    Plays Per Hour

    diff --git a/core/console/views/pages/analytics_page_templ.go b/core/console/views/pages/analytics_page_templ.go index fe98f9e11a4..2298ceee370 100644 --- a/core/console/views/pages/analytics_page_templ.go +++ b/core/console/views/pages/analytics_page_templ.go @@ -51,7 +51,7 @@ func (p *Pages) loadChart() templ.Component { }) } -func (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) templ.Component { +func (p *Pages) AnalyticsHeaderHTML(TotalBlocks, TotalTransactions, TotalPlays, TotalManageEntities, TotalValidators string) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -72,7 +72,101 @@ func (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Blocks

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(TotalBlocks) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 33, Col: 21} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Transactions

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(TotalTransactions) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 39, Col: 27} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Plays

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(TotalPlays) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 45, Col: 20} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Manage Entities

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(TotalManageEntities) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 51, Col: 29} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Validators

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var7 string + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(TotalValidators) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 57, Col: 25} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var8 := templ.GetChildren(ctx) + if templ_7745c5c3_Var8 == nil { + templ_7745c5c3_Var8 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -84,59 +178,7 @@ func (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Blocks

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.TotalBlocks) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 34, Col: 27} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Transactions

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var5 string - templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(data.TotalTransactions) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 40, Col: 33} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Total Plays

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.TotalPlays) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 46, Col: 26} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Validators

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(data.TotalValidators) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/analytics_page.templ`, Line: 52, Col: 31} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Plays Per Hour

    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Plays Per Hour

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -154,7 +196,7 @@ func (p *Pages) AnalyticsPageHTML(data *AnalyticsPageView) templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = p.layout.SiteFrame().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = p.layout.SiteFrame().Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/core/console/views/pages/nav_block_data.templ b/core/console/views/pages/nav_block_data.templ deleted file mode 100644 index dfe4159d9f9..00000000000 --- a/core/console/views/pages/nav_block_data.templ +++ /dev/null @@ -1,6 +0,0 @@ -package pages - -templ (p *Pages) NavBlockData(totalBlocks, totalTxs string) { -
    Total Blocks: { totalBlocks }
    -
    Total Transactions: { totalTxs }
    -} diff --git a/core/console/views/pages/nav_block_data_templ.go b/core/console/views/pages/nav_block_data_templ.go deleted file mode 100644 index 782c80563e1..00000000000 --- a/core/console/views/pages/nav_block_data_templ.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.778 -package pages - -//lint:file-ignore SA4006 This context is only used if a nested component is present. - -import "github.com/a-h/templ" -import templruntime "github.com/a-h/templ/runtime" - -func (p *Pages) NavBlockData(totalBlocks, totalTxs string) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var1 := templ.GetChildren(ctx) - if templ_7745c5c3_Var1 == nil { - templ_7745c5c3_Var1 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Total Blocks: ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var2 string - templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(totalBlocks) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/nav_block_data.templ`, Line: 4, Col: 33} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Total Transactions: ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var3 string - templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(totalTxs) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/nav_block_data.templ`, Line: 5, Col: 36} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/core/console/views/pages/overview_page.templ b/core/console/views/pages/overview_page.templ index 5c700dd704a..b3c692d0bde 100644 --- a/core/console/views/pages/overview_page.templ +++ b/core/console/views/pages/overview_page.templ @@ -7,8 +7,8 @@ import ( ) type OverviewPageView struct { - Block BlockView - Txs []db.CoreTxResult + Blocks []BlockView + Txs []db.CoreTxResult } func (p *Pages) OverviewPageJSON() {} @@ -18,27 +18,31 @@ templ (p *Pages) OverviewPageHTML(data *OverviewPageView) {
    -

    Latest Block

    -
    -
    - @p.components.Link("/block/%s", data.Block.Hash) { -
    Hash: { data.Block.Hash }
    - } -
    -
    - @p.components.Link("/nodes/%s", data.Block.Proposer) { -
    Proposer: { data.Block.Proposer }
    - } -
    -
    - @p.components.Link("/block/%s", data.Block.Height) { -
    Height: { data.Block.Height }
    - } -
    -
    - Age: { humanize.Time(data.Block.Timestamp) } +

    Recent Blocks

    + for _, block := range data.Blocks { +
    +
    +
    + @p.components.Link("/block/%s", block.Hash) { +
    Hash: { block.Hash }
    + } +
    +
    + @p.components.Link("/node/%s", block.Proposer) { +
    Proposer: { block.Proposer }
    + } +
    +
    + @p.components.Link("/block/%s", block.Height) { +
    Height: { block.Height }
    + } +
    +
    + Age: { humanize.Time(block.Timestamp) } +
    +
    -
    + }
    diff --git a/core/console/views/pages/overview_page_templ.go b/core/console/views/pages/overview_page_templ.go index 4ccec9c10d7..c469d327562 100644 --- a/core/console/views/pages/overview_page_templ.go +++ b/core/console/views/pages/overview_page_templ.go @@ -15,8 +15,8 @@ import ( ) type OverviewPageView struct { - Block BlockView - Txs []db.CoreTxResult + Blocks []BlockView + Txs []db.CoreTxResult } func (p *Pages) OverviewPageJSON() {} @@ -54,137 +54,147 @@ func (p *Pages) OverviewPageHTML(data *OverviewPageView) templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Latest Block

    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Recent Blocks

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Hash: ") + for _, block := range data.Blocks { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Block.Hash) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 25, Col: 36} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) - if templ_7745c5c3_Err != nil { + templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Hash: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(block.Hash) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 27, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + }) + templ_7745c5c3_Err = p.components.Link("/block/%s", block.Hash).Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = p.components.Link("/block/%s", data.Block.Hash).Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Proposer: ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.Block.Proposer) + templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Proposer: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(block.Proposer) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 32, Col: 41} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = p.components.Link("/node/%s", block.Proposer).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 30, Col: 44} + return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Height: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(block.Height) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 37, Col: 37} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = p.components.Link("/block/%s", block.Height).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = p.components.Link("/nodes/%s", data.Block.Proposer).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Height: ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Age: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var8 string - templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(data.Block.Height) + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(humanize.Time(block.Timestamp)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 35, Col: 40} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 41, Col: 46} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = p.components.Link("/block/%s", data.Block.Height).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    Age: ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(humanize.Time(data.Block.Timestamp)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 39, Col: 49} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Recent Transactions

    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Recent Transactions

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -205,7 +215,7 @@ func (p *Pages) OverviewPageHTML(data *OverviewPageView) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(tx.TxHash) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 51, Col: 90} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 55, Col: 90} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -227,7 +237,7 @@ func (p *Pages) OverviewPageHTML(data *OverviewPageView) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(tx.BlockID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 53, Col: 118} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 57, Col: 118} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -240,7 +250,7 @@ func (p *Pages) OverviewPageHTML(data *OverviewPageView) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(humanize.Time(tx.CreatedAt.Time)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 54, Col: 53} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/pages/overview_page.templ`, Line: 58, Col: 53} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { diff --git a/core/console/views/views.go b/core/console/views/views.go index 111da233faa..00b78242bd2 100644 --- a/core/console/views/views.go +++ b/core/console/views/views.go @@ -2,22 +2,25 @@ package views import ( "github.com/AudiusProject/audius-protocol/core/config" + "github.com/AudiusProject/audius-protocol/core/console/views/layout" "github.com/AudiusProject/audius-protocol/core/console/views/pages" "github.com/labstack/echo/v4" ) type Views struct { - pages *pages.Pages + pages *pages.Pages + layouts *layout.Layout } func NewViews(config *config.Config, baseUrl string) *Views { return &Views{ - pages: pages.NewPages(config, baseUrl), + pages: pages.NewPages(config, baseUrl), + layouts: layout.NewLayout(config, baseUrl), } } func (v *Views) RenderNavChainData(c echo.Context, totalBlocks, totalTxs string) error { - return v.pages.NavBlockData(totalBlocks, totalTxs).Render(c.Request().Context(), c.Response().Writer) + return v.layouts.NavBlockData(totalBlocks, totalTxs).Render(c.Request().Context(), c.Response().Writer) } func (v *Views) RenderOverviewView(c echo.Context, data *pages.OverviewPageView) error { @@ -36,6 +39,10 @@ func (v *Views) RenderAnalyticsView(c echo.Context, view *pages.AnalyticsPageVie return v.pages.AnalyticsPageHTML(view).Render(c.Request().Context(), c.Response().Writer) } +func (v *Views) RenderAnalyticsHeader(c echo.Context, totalBlocks string, totalTransactions string, totalPlays string, totalManageEntities string, totalValidators string) error { + return v.pages.AnalyticsHeaderHTML(totalBlocks, totalTransactions, totalPlays, totalManageEntities, totalValidators).Render(c.Request().Context(), c.Response().Writer) +} + func (v *Views) RenderContentView(c echo.Context) error { return v.pages.ContentPageHTML().Render(c.Request().Context(), c.Response().Writer) } diff --git a/core/go.mod b/core/go.mod index 9d755b14189..2816a05a1b5 100644 --- a/core/go.mod +++ b/core/go.mod @@ -4,7 +4,6 @@ go 1.22.5 require ( github.com/a-h/templ v0.2.778 - github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/gogoproto v1.7.0 github.com/dustin/go-humanize v1.0.1 github.com/improbable-eng/grpc-web v0.15.0 @@ -33,6 +32,7 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.0 // indirect + github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect diff --git a/core/grpc/constants.go b/core/grpc/constants.go index 8ead039ffa5..0782b74c193 100644 --- a/core/grpc/constants.go +++ b/core/grpc/constants.go @@ -9,13 +9,15 @@ import ( ) var ( - TrackPlaysProtoName string - SlaRollupProtoName string - SlaNodeReportProtoName string + TrackPlaysProtoName string + ManageEntitiesProtoName string + SlaRollupProtoName string + SlaNodeReportProtoName string ) func init() { TrackPlaysProtoName = GetProtoTypeName(&gen_proto.TrackPlays{}) + ManageEntitiesProtoName = GetProtoTypeName(&gen_proto.ManageEntityLegacy{}) SlaRollupProtoName = GetProtoTypeName(&gen_proto.SlaRollup{}) SlaNodeReportProtoName = GetProtoTypeName(&gen_proto.SlaNodeReport{}) }