Documentation ¶
Overview ¶
Package explorer handles the block explorer subsystem for generating the explorer pages.
Index ¶
- Constants
- func AddressPathCtx(next http.Handler) http.Handler
- func AgendaPathCtx(next http.Handler) http.Handler
- func DisableLog()
- func MenuFormParser(next http.Handler) http.Handler
- func New(cfg *ExplorerConfig) *explorerUI
- func ProposalPathCtx(next http.Handler) http.Handler
- func TicketStatusText(s dbtypes.TicketSpendType, p dbtypes.TicketPoolStatus) string
- func TransactionHashCtx(next http.Handler) http.Handler
- func TransactionIoIndexCtx(next http.Handler) http.Handler
- func UseLogger(logger slog.Logger)
- type CommonPageData
- type Cookies
- type ExplorerConfig
- type PoliteiaBackend
- type SyncStatusInfo
- type WebSocketMessage
- type WebsocketExchangeUpdate
- type WebsocketHub
- func (wsh *WebsocketHub) AreDBsSyncing() bool
- func (wsh *WebsocketHub) NumClients() int
- func (wsh *WebsocketHub) RegisterClient(c *hubSpoke, xcChan exchangeChannel) *client
- func (wsh *WebsocketHub) SetDBsSyncing(syncing bool)
- func (wsh *WebsocketHub) Stop()
- func (wsh *WebsocketHub) UnregisterClient(c *hubSpoke)
- type WebsocketMiniExchange
Constants ¶
const ( ExpStatusError expStatus = "Error" ExpStatusNotFound expStatus = "Not Found" ExpStatusFutureBlock expStatus = "Future Block" ExpStatusNotSupported expStatus = "Not Supported" ExpStatusBadRequest expStatus = "Bad Request" ExpStatusNotImplemented expStatus = "Not Implemented" ExpStatusPageDisabled expStatus = "Page Disabled" ExpStatusWrongNetwork expStatus = "Wrong Network" ExpStatusDeprecated expStatus = "Deprecated" ExpStatusSyncing expStatus = "Blocks Syncing" ExpStatusDBTimeout expStatus = "Database Timeout" ExpStatusP2PKAddress expStatus = "P2PK Address Type" )
These are the explorer status messages used by the status page.
const ( // MaxAddressRows is an upper limit on the number of rows that may be shown // on the address page table. MaxAddressRows int64 = 160 )
Variables ¶
This section is empty.
Functions ¶
func AddressPathCtx ¶
AddressPathCtx embeds "address" into the request context
func AgendaPathCtx ¶
AgendaPathCtx embeds "agendaid" into the request context
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func MenuFormParser ¶
MenuFormParser parses a form submission from the navigation menu.
func New ¶
func New(cfg *ExplorerConfig) *explorerUI
New returns an initialized instance of explorerUI
func ProposalPathCtx ¶
ProposalPathCtx embeds "proposalrefID" into the request context
func TicketStatusText ¶
func TicketStatusText(s dbtypes.TicketSpendType, p dbtypes.TicketPoolStatus) string
TicketStatusText generates the text to display on the explorer's transaction page for the "POOL STATUS" field.
func TransactionHashCtx ¶
TransactionHashCtx embeds "txid" into the request context
func TransactionIoIndexCtx ¶
TransactionIoIndexCtx embeds "inout" and "inoutid" into the request context
Types ¶
type CommonPageData ¶
type CommonPageData struct { Tip *types.WebBasicBlock Version string ChainParams *chaincfg.Params BlockTimeUnix int64 DevAddress string Links *links NetName string Cookies Cookies RequestURI string }
CommonPageData is the basis for data structs used for HTML templates. explorerUI.commonData returns an initialized instance or CommonPageData, which itself should be used to initialize page data template structs.
type Cookies ¶
type Cookies struct {
DarkMode bool
}
Cookies contains information from the request cookies.
type ExplorerConfig ¶
type ExplorerConfig struct { DataSource explorerDataSourceLite PrimaryDataSource explorerDataSource UseRealIP bool AppVersion string DevPrefetch bool Viewsfolder string XcBot *exchanges.ExchangeBot AgendasSource agendaBackend Tracker *agendas.VoteTracker ProposalsSource PoliteiaBackend PoliteiaURL string MainnetLink string TestnetLink string }
ExplorerConfig is the configuration settings for explorerUI.
type PoliteiaBackend ¶
type PoliteiaBackend interface { LastProposalsSync() int64 CheckProposalsUpdates() error AllProposals(offset, rowsCount int, filterByVoteStatus ...int) (proposals []*pitypes.ProposalInfo, totalCount int, err error) ProposalByToken(proposalToken string) (*pitypes.ProposalInfo, error) ProposalByRefID(RefID string) (*pitypes.ProposalInfo, error) }
PoliteiaBackend implements methods that manage proposals db data.
type SyncStatusInfo ¶
type SyncStatusInfo struct { // PercentComplete is the percentage of sync complete for a given progress bar. PercentComplete float64 `json:"percentage_complete"` // BarMsg holds the main bar message about the currect sync. BarMsg string `json:"bar_msg"` // BarSubtitle holds any other information about the current main sync. This // value may include but not limited to; db indexing, deleting duplicates etc. BarSubtitle string `json:"subtitle"` // Time is the estimated time in seconds to the sync should be complete. Time int64 `json:"seconds_to_complete"` // ProgressBarID is the given entry progress bar id needed on the UI page. ProgressBarID string `json:"progress_bar_id"` }
SyncStatusInfo defines information for a single progress bar.
func SyncStatus ¶
func SyncStatus() []SyncStatusInfo
SyncStatus defines a thread-safe way to read the sync status updates
type WebSocketMessage ¶
WebSocketMessage represents the JSON object used to send and received typed messages to the web client.
type WebsocketExchangeUpdate ¶
type WebsocketExchangeUpdate struct { Updater WebsocketMiniExchange `json:"updater"` IsFiatIndex bool `json:"fiat"` BtcIndex string `json:"index"` Price float64 `json:"price"` BtcPrice float64 `json:"btc_price"` Volume float64 `json:"volume"` }
WebsocketExchangeUpdate is an update to the exchange state to send over the websocket.
type WebsocketHub ¶
type WebsocketHub struct { Register chan *clientHubSpoke Unregister chan *hubSpoke HubRelay chan hubMessage // contains filtered or unexported fields }
WebsocketHub and its event loop manage all websocket client connections. WebsocketHub is responsible for closing all connections registered with it. If the event loop is running, calling (*WebsocketHub).Stop() will handle it.
func NewWebsocketHub ¶
func NewWebsocketHub() *WebsocketHub
NewWebsocketHub creates a new WebsocketHub
func (*WebsocketHub) AreDBsSyncing ¶
func (wsh *WebsocketHub) AreDBsSyncing() bool
AreDBsSyncing is a thread-safe way to fetch the boolean in dbsSyncing.
func (*WebsocketHub) NumClients ¶
func (wsh *WebsocketHub) NumClients() int
NumClients returns the number of clients connected to the websocket hub.
func (*WebsocketHub) RegisterClient ¶
func (wsh *WebsocketHub) RegisterClient(c *hubSpoke, xcChan exchangeChannel) *client
RegisterClient registers a websocket connection with the hub, and returns a pointer to the new client data object.
func (*WebsocketHub) SetDBsSyncing ¶
func (wsh *WebsocketHub) SetDBsSyncing(syncing bool)
SetDBsSyncing is a thread-safe way to update the dbsSyncing.
func (*WebsocketHub) Stop ¶
func (wsh *WebsocketHub) Stop()
Stop kills the run() loop and unregisters all clients (connections).
func (*WebsocketHub) UnregisterClient ¶
func (wsh *WebsocketHub) UnregisterClient(c *hubSpoke)
UnregisterClient unregisters the input websocket connection via the main run() loop. This call will block if the run() loop is not running.