{"modulePath":"github.com/parallelcointeam/exploder","version":"v2.1.3+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package explorer\n\nPackage explorer handles the block explorer subsystem for generating the explorer pages. Copyright (c) 2017, The dcrdata developers See LICENSE for details.\n\n## Constants\n\n```go\nconst (\n\tMaxAddressRows         int64 = 1000\n\tMaxUnconfirmedPossible int64 = 1000\n)\n```\n\n```go\nconst NumLatestMempoolTxns = 5\n```\nNumLatestMempoolTxns is the maximum number of mempool transactions that will be stored in MempoolData.LatestTransactions.\n\n## Variables\n\n```go\nvar ErrWsClosed = \"use of closed network connection\"\n```\n\n## Functions\n\n```go\nfunc AddressPathCtx(next http.Handler) http.Handler\n```\nAddressPathCtx embeds \"address\" into the request context\n\n```go\nfunc DisableLog()\n```\nDisableLog disables all library log output.  Logging output is disabled by default until UseLogger is called.\n\n```go\nfunc New(dataSource explorerDataSourceLite, primaryDataSource explorerDataSource,\n\tuseRealIP bool, appVersion string, devPrefetch bool) *explorerUI\n```\nNew returns an initialized instance of explorerUI\n\n```go\nfunc TicketStatusText(s dbtypes.TicketSpendType, p dbtypes.TicketPoolStatus) string\n```\nTicketStatusText generates the text to display on the explorer's transaction page for the \"POOL STATUS\" field.\n\n```go\nfunc TransactionHashCtx(next http.Handler) http.Handler\n```\nTransactionHashCtx embeds \"txid\" into the request context\n\n```go\nfunc UseLogger(logger slog.Logger)\n```\nUseLogger uses a specified Logger to output package logging info.\n\n## Types\n\n```go\ntype AddrPrefix struct {\n\tName        string\n\tPrefix      string\n\tDescription string\n}\n```\nAddrPrefix represent the address name it's prefix and description\n\n```go\nfunc AddressPrefixes(params *chaincfg.Params) []AddrPrefix\n```\nAddressPrefixes generates an array AddrPrefix by using chaincfg.Params\n\n```go\ntype AddressBalance struct {\n\tAddress      string `json:\"address\"`\n\tNumSpent     int64  `json:\"num_stxos\"`\n\tNumUnspent   int64  `json:\"num_utxos\"`\n\tTotalSpent   int64  `json:\"amount_spent\"`\n\tTotalUnspent int64  `json:\"amount_unspent\"`\n}\n```\nAddressBalance represents the number and value of spent and unspent outputs for an address.\n\n```go\ntype AddressInfo struct {\n\t// Address is the decred address on the current page\n\tAddress string\n\n\t// Page parameters\n\tMaxTxLimit    int64\n\tFullmode      bool\n\tPath          string\n\tLimit, Offset int64  // ?n=Limit\u0026start=Offset\n\tTxnType       string // ?txntype=TxnType\n\n\t// NumUnconfirmed is the number of unconfirmed txns for the address\n\tNumUnconfirmed  int64\n\tUnconfirmedTxns *AddressTransactions\n\n\t// Transactions on the current page\n\tTransactions    []*AddressTx\n\tTxnsFunding     []*AddressTx\n\tTxnsSpending    []*AddressTx\n\tNumTransactions int64 // The number of transactions in the address\n\tNumFundingTxns  int64 // number paying to the address\n\tNumSpendingTxns int64 // number spending outpoints associated with the address\n\tAmountReceived  dcrutil.Amount\n\tAmountSent      dcrutil.Amount\n\tAmountUnspent   dcrutil.Amount\n\n\t// Balance is used in full mode, describing all known transactions\n\tBalance *AddressBalance\n\n\t// KnownTransactions refers to the total transaction count in the DB when in\n\t// full mode, the sum of funding (crediting) and spending (debiting) txns.\n\tKnownTransactions int64\n\tKnownFundingTxns  int64\n\tKnownSpendingTxns int64\n}\n```\nAddressInfo models data for display on the address page\n\n```go\nfunc ReduceAddressHistory(addrHist []*dbtypes.AddressRow) *AddressInfo\n```\nReduceAddressHistory generates a template AddressInfo from a slice of dbtypes.AddressRow. All fields except NumUnconfirmed and Transactions are set completely. Transactions is partially set, with each transaction having only the TxID and ReceivedTotal set. The rest of the data should be filled in by other means, such as RPC calls or database queries.\n\n```go\nfunc (a *AddressInfo) TxnCount() int64\n```\nTxnCount returns the number of transaction \"rows\" available.\n\n```go\ntype AddressTransactions struct {\n\tTransactions []*AddressTx\n\tTxnsFunding  []*AddressTx\n\tTxnsSpending []*AddressTx\n}\n```\nAddressTransactions collects the transactions for an address as AddressTx slices.\n\n```go\ntype AddressTx struct {\n\tTxID          string\n\tInOutID       uint32\n\tSize          uint32\n\tFormattedSize string\n\tTotal         float64\n\tConfirmations uint64\n\tTime          int64\n\tFormattedTime string\n\tReceivedTotal float64\n\tSentTotal     float64\n}\n```\nAddressTx models data for transactions on the address page\n\n```go\nfunc (a *AddressTx) IOID() string\n```\nIOID formats an identification string for the transaction input (or output) represented by the AddressTx.\n\n```go\ntype BlockBasic struct {\n\tHeight         int64  `json:\"height\"`\n\tSize           int32  `json:\"size\"`\n\tValid          bool   `json:\"valid\"`\n\tVoters         uint16 `json:\"votes\"`\n\tTransactions   int    `json:\"tx\"`\n\tFreshStake     uint8  `json:\"tickets\"`\n\tRevocations    uint32 `json:\"revocations\"`\n\tBlockTime      int64  `json:\"time\"`\n\tFormattedTime  string `json:\"formatted_time\"`\n\tFormattedBytes string `json:\"formatted_bytes\"`\n}\n```\nBlockBasic models data for the explorer's explorer page\n\n```go\ntype BlockInfo struct {\n\t*BlockBasic\n\tHash                  string\n\tVersion               int32\n\tConfirmations         int64\n\tStakeRoot             string\n\tMerkleRoot            string\n\tTxAvailable           bool\n\tTx                    []*TxBasic\n\tTickets               []*TxBasic\n\tRevs                  []*TxBasic\n\tVotes                 []*TxBasic\n\tMisses                []string\n\tNonce                 uint32\n\tVoteBits              uint16\n\tFinalState            string\n\tPoolSize              uint32\n\tBits                  string\n\tSBits                 float64\n\tDifficulty            float64\n\tExtraData             string\n\tStakeVersion          uint32\n\tPreviousHash          string\n\tNextHash              string\n\tTotalSent             float64\n\tMiningFee             dcrutil.Amount\n\tStakeValidationHeight int64\n}\n```\nBlockInfo models data for display on the block page\n\n```go\ntype BlockSubsidy struct {\n\tTotal int64 `json:\"total\"`\n\tPoW   int64 `json:\"pow\"`\n\tPoS   int64 `json:\"pos\"`\n\tDev   int64 `json:\"dev\"`\n}\n```\nBlockSubsidy is an implementation of dcrjson.GetBlockSubsidyResult\n\n```go\ntype BlockValidation struct {\n\tHash     string `json:\"hash\"`\n\tHeight   int64  `json:\"height\"`\n\tValidity bool   `json:\"validity\"`\n}\n```\nBlockValidation models data about a vote's decision on a block\n\n```go\ntype ChainParams struct {\n\tWindowSize       int64 `json:\"window_size\"`\n\tRewardWindowSize int64 `json:\"reward_window_size\"`\n\tTargetPoolSize   int64 `json:\"target_pool_size\"`\n\tBlockTime        int64 `json:\"target_block_time\"`\n\tMeanVotingBlocks int64\n}\n```\nChainParams models simple data about the chain server's parameters used for some info on the front page\n\n```go\ntype ExtendedChainParams struct {\n\tParams               *chaincfg.Params\n\tActualTicketPoolSize int64\n\tAddressPrefix        []AddrPrefix\n}\n```\nExtendedChainParams represents the data of ChainParams\n\n```go\ntype HomeInfo struct {\n\tCoinSupply        int64          `json:\"coin_supply\"`\n\tStakeDiff         float64        `json:\"sdiff\"`\n\tIdxBlockInWindow  int            `json:\"window_idx\"`\n\tIdxInRewardWindow int            `json:\"reward_idx\"`\n\tDifficulty        float64        `json:\"difficulty\"`\n\tDevFund           int64          `json:\"dev_fund\"`\n\tDevAddress        string         `json:\"dev_address\"`\n\tTicketReward      float64        `json:\"reward\"`\n\tRewardPeriod      string         `json:\"reward_period\"`\n\tASR               float64        `json:\"ASR\"`\n\tNBlockSubsidy     BlockSubsidy   `json:\"subsidy\"`\n\tParams            ChainParams    `json:\"params\"`\n\tPoolInfo          TicketPoolInfo `json:\"pool_info\"`\n}\n```\nHomeInfo represents data used for the home page\n\n```go\ntype MempoolInfo struct {\n\tsync.RWMutex\n\tMempoolShort\n\tTransactions []MempoolTx `json:\"tx\"`\n\tTickets      []MempoolTx `json:\"tickets\"`\n\tVotes        []MempoolTx `json:\"votes\"`\n\tRevocations  []MempoolTx `json:\"revs\"`\n}\n```\nMempoolInfo models data to update mempool info on the home page\n\n```go\ntype MempoolShort struct {\n\tLastBlockHeight    int64          `json:\"block_height\"`\n\tLastBlockTime      int64          `json:\"block_time\"`\n\tTotalOut           float64        `json:\"total\"`\n\tTotalSize          int32          `json:\"size\"`\n\tNumTickets         int            `json:\"num_tickets\"`\n\tNumVotes           int            `json:\"num_votes\"`\n\tNumRegular         int            `json:\"num_regular\"`\n\tNumRevokes         int            `json:\"num_revokes\"`\n\tNumAll             int            `json:\"num_all\"`\n\tLatestTransactions []MempoolTx    `json:\"latest\"`\n\tFormattedTotalSize string         `json:\"formatted_size\"`\n\tTicketIndexes      map[string]int `json:\"ticket_indexes\"`\n}\n```\nMempoolShort represents the mempool data sent as the mempool update\n\n```go\ntype MempoolTx struct {\n\tHash     string    `json:\"hash\"`\n\tTime     int64     `json:\"time\"`\n\tSize     int32     `json:\"size\"`\n\tTotalOut float64   `json:\"total\"`\n\tType     string    `json:\"Type\"`\n\tVoteInfo *VoteInfo `json:\"vote_info\"`\n}\n```\nMempoolTx models the tx basic data for the mempool page\n\n```go\ntype NewMempoolTx struct {\n\tTime int64\n\tHex  string\n}\n```\nNewMempoolTx models data sent from the notification handler\n\n```go\ntype TicketInfo struct {\n\tTicketMaturity       int64\n\tTimeTillMaturity     float64 // Time before a particular ticket reaches maturity, in hours\n\tPoolStatus           string\n\tSpendStatus          string\n\tTicketPoolSize       int64   // Total number of ticket in the pool\n\tTicketExpiry         int64   // Total number of blocks before a ticket expires\n\tTicketExpiryDaysLeft float64 // Approximate days left before the given ticket expires\n\tTicketLiveBlocks     int64   // Total number of confirms after maturity and up until the point the ticket votes or expires\n\tBestLuck             int64   // Best possible Luck for voting\n\tAvgLuck              int64   // Average Luck for voting\n\tVoteLuck             float64 // Actual Luck for voting on a ticket\n\tLuckStatus           string  // Short discription based on the VoteLuck\n\tProbability          float64 // Probability of success before ticket expires\n}\n```\nTicketInfo is used to represent data shown for a sstx transaction.\n\n```go\ntype TicketPoolInfo struct {\n\tSize          uint32  `json:\"size\"`\n\tValue         float64 `json:\"value\"`\n\tValAvg        float64 `json:\"valavg\"`\n\tPercentage    float64 `json:\"percent\"`\n\tTarget        uint16  `json:\"target\"`\n\tPercentTarget float64 `json:\"percent_target\"`\n}\n```\nTicketPoolInfo describes the live ticket pool\n\n```go\ntype TxBasic struct {\n\tTxID          string\n\tFormattedSize string\n\tTotal         float64\n\tFee           dcrutil.Amount\n\tFeeRate       dcrutil.Amount\n\tVoteInfo      *VoteInfo\n\tCoinbase      bool\n}\n```\nTxBasic models data for transactions on the block page\n\n```go\ntype TxInID struct {\n\tHash  string\n\tIndex uint32\n}\n```\nTxInID models the identity of a spending transaction input\n\n```go\ntype TxInfo struct {\n\t*TxBasic\n\tSpendingTxns     []TxInID\n\tType             string\n\tVin              []Vin\n\tVout             []Vout\n\tBlockHeight      int64\n\tBlockIndex       uint32\n\tBlockHash        string\n\tBlockMiningFee   int64\n\tConfirmations    int64\n\tTime             int64\n\tFormattedTime    string\n\tMature           string\n\tVoteFundsLocked  string\n\tMaturity         int64   // Total number of blocks before mature\n\tMaturityTimeTill float64 // Time in hours until mature\n\tTicketInfo\n}\n```\nTxInfo models data needed for display on the tx page\n\n```go\nfunc (t *TxInfo) IsTicket() bool\n```\n\n```go\nfunc (t *TxInfo) IsVote() bool\n```\n\n```go\ntype Vin struct {\n\t*dcrjson.Vin\n\tAddresses       []string\n\tFormattedAmount string\n}\n```\nVin models basic data about a tx input for display\n\n```go\ntype VoteInfo struct {\n\tValidation         BlockValidation         `json:\"block_validation\"`\n\tVersion            uint32                  `json:\"vote_version\"`\n\tBits               uint16                  `json:\"vote_bits\"`\n\tChoices            []*txhelpers.VoteChoice `json:\"vote_choices\"`\n\tTicketSpent        string                  `json:\"ticket_spent\"`\n\tMempoolTicketIndex int                     `json:\"mempool_ticket_index\"`\n}\n```\nVoteInfo models data about a SSGen transaction (vote)\n\n```go\ntype Vout struct {\n\tAddresses       []string\n\tAmount          float64\n\tFormattedAmount string\n\tType            string\n\tSpent           bool\n\tOP_RETURN       string\n}\n```\nVout models basic data about a tx output for display\n\n```go\ntype WebSocketMessage struct {\n\tEventId string `json:\"event\"`\n\tMessage string `json:\"message\"`\n}\n```\nWebSocketMessage represents the JSON object used to send and received typed messages to the web client.\n\n```go\ntype WebsocketBlock struct {\n\tBlock *BlockBasic `json:\"block\"`\n\tExtra *HomeInfo   `json:\"extra\"`\n}\n```\nWebsocketBlock wraps the new block info for use in the websocket\n\n```go\ntype WebsocketHub struct {\n\tRegister   chan *clientHubSpoke\n\tUnregister chan *hubSpoke\n\tHubRelay   chan hubSignal\n\tNewTxChan  chan *MempoolTx\n\t// contains filtered or unexported fields\n}\n```\nWebsocketHub 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.\n\n```go\nfunc NewWebsocketHub() *WebsocketHub\n```\nNewWebsocketHub creates a new WebsocketHub\n\n```go\nfunc (wsh *WebsocketHub) MaybeSendTxns(tx *MempoolTx)\n```\nMaybeSendTxns 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.\n\n```go\nfunc (wsh *WebsocketHub) NumClients() int\n```\nNumClients returns the number of clients connected to the websocket hub\n\n```go\nfunc (wsh *WebsocketHub) RegisterClient(c *hubSpoke) *client\n```\nRegisterClient registers a websocket connection with the hub, and returns a pointer to the new client data object.\n\n```go\nfunc (wsh *WebsocketHub) Stop()\n```\nStop kills the run() loop and unregisteres all clients (connections).\n\n```go\nfunc (wsh *WebsocketHub) UnregisterClient(c *hubSpoke)\n```\nUnregisterClient unregisters the input websocket connection via the main run() loop.  This call will block if the run() loop is not running.\n\n","path":"github.com/parallelcointeam/exploder/explorer","name":"explorer","synopsis":"Package explorer handles the block explorer subsystem for generating the explorer pages.","isRedistributable":true}
