explorer

package
v5.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2019 License: ISC Imports: 45 Imported by: 0

Documentation

Overview

Package explorer handles the block explorer subsystem for generating the explorer pages.

Index

Constants

View Source
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.

View Source
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

func AddressPathCtx(next http.Handler) http.Handler

AddressPathCtx embeds "address" into the request context

func AgendaPathCtx

func AgendaPathCtx(next http.Handler) http.Handler

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(next http.Handler) http.Handler

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

func ProposalPathCtx(next http.Handler) http.Handler

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

func TransactionHashCtx(next http.Handler) http.Handler

TransactionHashCtx embeds "txid" into the request context

func TransactionIoIndexCtx

func TransactionIoIndexCtx(next http.Handler) http.Handler

TransactionIoIndexCtx embeds "inout" and "inoutid" into the request context

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

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

type WebSocketMessage struct {
	EventId string `json:"event"`
	Message string `json:"message"`
}

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.

type WebsocketMiniExchange

type WebsocketMiniExchange struct {
	Token  string  `json:"token"`
	Price  float64 `json:"price"`
	Volume float64 `json:"volume"`
	Change float64 `json:"change"`
}

WebsocketMiniExchange is minimal info regarding the exchange that triggered an update.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL