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 ProxyHeaders(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 ChartDataSource
- type CommonPageData
- type Cookies
- type ExplorerConfig
- type SyncStatusInfo
- type TreasuryInfo
- 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 ( // MaxAddressRows is an upper limit on the number of rows that may be shown // on the address page table. MaxAddressRows int64 = 160 MaxTreasuryRows int64 = 200 )
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.
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 "proposaltoken" into the request context
func ProxyHeaders ¶
ProxyHeaders should only be used when behind a trusted proxy, not with direct client connections. This sets Request.URL.Scheme from X-Forwarded-Proto, then X-Forwarded-Scheme, and falls back to the scheme implied by the Request.TLS field. This also sets Request.Host if X-Forwarded-Host was set, but Request.Host is usually already preserved by well-configured reverse proxies.
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 ChartDataSource ¶
type ChartDataSource interface {
AnonymitySet() uint64
}
ChartDataSource provides data from the charts cache.
type CommonPageData ¶
type CommonPageData struct { Tip *types.WebBasicBlock Version string ChainParams *chaincfg.Params BlockTimeUnix int64 Links *links NetName string Cookies Cookies Host string BaseURL string // scheme + "://" + "host" Path string RequestURI string // path?query }
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.
func (*CommonPageData) CanonicalURL ¶
func (cp *CommonPageData) CanonicalURL() string
CanonicalURL constructs the page's canonical URL. According to Facebook: "This should be the undecorated URL, without session variables, user identifying parameters, or counters. Likes and Shares for this URL will aggregate at this URL." https://developers.facebook.com/docs/sharing/webmasters/
func (*CommonPageData) FullURL ¶
func (cp *CommonPageData) FullURL() string
FullURL constructs the page's complete URL.
type Cookies ¶
type Cookies struct {
DarkMode bool
}
Cookies contains information from the request cookies.
type ExplorerConfig ¶
type ExplorerConfig struct { DataSource explorerDataSource ChartSource ChartDataSource UseRealIP bool AppVersion string DevPrefetch bool Viewsfolder string XcBot *exchanges.ExchangeBot AgendasSource agendaBackend Tracker *agendas.VoteTracker MainnetLink string TestnetLink string OnionAddress string ReloadHTML bool }
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 TreasuryInfo ¶
type TreasuryInfo struct { Net string // Page parameters MaxTxLimit int64 Path string Limit, Offset int64 // ?n=Limit&start=Offset TxnType string // ?txntype=TxnType // Transactions on the current page Transactions []*dbtypes.TreasuryTx NumTransactions int64 // len(Transactions) but int64 for dumb template Balance *dbtypes.TreasuryBalance ConvertedBalance *exchanges.Conversion TypeCount int64 }
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.