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 ChartTypeData(chartType string) (data *dbtypes.ChartsData, ok bool)
- func DisableLog()
- 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 ExplorerConfig
- type SyncStatusInfo
- type WebSocketMessage
- type WebsocketHub
- func (wsh *WebsocketHub) AreDBsSyncing() bool
- func (wsh *WebsocketHub) MaybeSendTxns(tx *types.MempoolTx)
- func (wsh *WebsocketHub) NumClients() int
- func (wsh *WebsocketHub) RegisterClient(c *hubSpoke) *client
- func (wsh *WebsocketHub) SetDBsSyncing(syncing bool)
- func (wsh *WebsocketHub) Stop()
- func (wsh *WebsocketHub) UnregisterClient(c *hubSpoke)
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" ExpStatusWrongNetwork expStatus = "Wrong Network" ExpStatusDeprecated expStatus = "Deprecated" ExpStatusSyncing expStatus = "Blocks Syncing" ExpStatusDBTimeout expStatus = "Database Timeout" ExpStatusP2PKAddress expStatus = "P2PK Address Type" )
const ( // MaxAddressRows is an upper limit on the number of rows that may be shown // on the address page table. MaxAddressRows int64 = 1000 )
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 ChartTypeData ¶
func ChartTypeData(chartType string) (data *dbtypes.ChartsData, ok bool)
ChartTypeData is a thread-safe way to access chart data of the given type.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func New ¶
func New(cfg *ExplorerConfig) *explorerUI
New returns an initialized instance of explorerUI
func ProposalPathCtx ¶
ProposalPathCtx embeds "proposalToken" 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 }
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 ExplorerConfig ¶
type ExplorerConfig struct { DataSource explorerDataSourceLite PrimaryDataSource explorerDataSource UseRealIP bool AppVersion string DevPrefetch bool Viewsfolder string XcBot *exchanges.ExchangeBot AgendasSource agendaBackend ProposalsSource politeiaBackend PoliteiaURL string MainnetLink string TestnetLink string }
ExplorerConfig is the configuration settings for explorerUI.
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 WebsocketHub ¶
type WebsocketHub struct { Register chan *clientHubSpoke Unregister chan *hubSpoke HubRelay chan hubSignal NewTxChan chan *types.MempoolTx // 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) MaybeSendTxns ¶
func (wsh *WebsocketHub) MaybeSendTxns(tx *types.MempoolTx)
MaybeSendTxns adds a mempool transaction to the client broadcast buffer. If the buffer is at capacity, a goroutine is launched to signal for the transactions to be sent to the clients.
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) *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 unregisteres 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.