Documentation

Overview

    Package explorer handles the block explorer subsystem for generating the explorer pages. Copyright (c) 2017, The dcrdata developers See LICENSE for details.

    Index

    Constants

    View Source
    const (
    	MaxAddressRows         int64 = 1000
    	MaxUnconfirmedPossible int64 = 1000
    )

    Variables

    This section is empty.

    Functions

    func AddressPathCtx

    func AddressPathCtx(next http.Handler) http.Handler

      AddressPathCtx embeds "address" 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 New

        func New(dataSource explorerDataSourceLite, primaryDataSource explorerDataSource,
        	useRealIP bool, appVersion string) *explorerUI

          New returns an initialized instance of explorerUI

          func TransactionHashCtx

          func TransactionHashCtx(next http.Handler) http.Handler

            TransactionHashCtx embeds "txid" into the request context

            func UseLogger

            func UseLogger(logger btclog.Logger)

              UseLogger uses a specified Logger to output package logging info.

              Types

              type AddressBalance

              type AddressBalance struct {
              	Address      string
              	NumSpent     int64
              	NumUnspent   int64
              	TotalSpent   int64
              	TotalUnspent int64
              }

                AddressBalance represents the number and value of spent and unspent outputs for an address.

                type AddressInfo

                type AddressInfo struct {
                	Address           string
                	Limit             int64
                	MaxTxLimit        int64
                	Offset            int64
                	Transactions      []*AddressTx
                	NumFundingTxns    int64 // The number of transactions paying to the address
                	NumSpendingTxns   int64 // The number of transactions spending from the address
                	NumTransactions   int64 // The number of transactions in the address
                	KnownTransactions int64 // The number of transactions in the address unlimited
                	KnownFundingTxns  int64 // The number of transactions paying to the address unlimited
                	NumUnconfirmed    int64 // The number of unconfirmed transactions in the address
                	TotalReceived     dcrutil.Amount
                	TotalSent         dcrutil.Amount
                	Unspent           dcrutil.Amount
                	Balance           *AddressBalance
                	Path              string
                	Fullmode          bool
                }

                  AddressInfo models data for display on the address page

                  func ReduceAddressHistory

                  func ReduceAddressHistory(addrHist []*dbtypes.AddressRow) *AddressInfo

                    ReduceAddressHistory 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.

                    type AddressTx

                    type AddressTx struct {
                    	TxID          string
                    	FormattedSize string
                    	Total         float64
                    	Confirmations uint64
                    	Time          int64
                    	FormattedTime string
                    	RecievedTotal float64
                    	SentTotal     float64
                    }

                      AddressTx models data for transactions on the address page

                      type BlockBasic

                      type BlockBasic struct {
                      	Height         int64  `json:"height"`
                      	Size           int32  `json:"size"`
                      	Valid          bool   `json:"valid"`
                      	Voters         uint16 `json:"votes"`
                      	Transactions   int    `json:"tx"`
                      	FreshStake     uint8  `json:"tickets"`
                      	Revocations    uint32 `json:"revocations"`
                      	BlockTime      int64  `json:"time"`
                      	FormattedTime  string `json:"formatted_time"`
                      	FormattedBytes string
                      }

                        BlockBasic models data for the explorer's explorer page

                        type BlockInfo

                        type BlockInfo struct {
                        	*BlockBasic
                        	Hash                  string
                        	Version               int32
                        	Confirmations         int64
                        	StakeRoot             string
                        	MerkleRoot            string
                        	TxAvailable           bool
                        	Tx                    []*TxBasic
                        	Tickets               []*TxBasic
                        	Revs                  []*TxBasic
                        	Votes                 []*TxBasic
                        	Nonce                 uint32
                        	VoteBits              uint16
                        	FinalState            string
                        	PoolSize              uint32
                        	Bits                  string
                        	SBits                 float64
                        	Difficulty            float64
                        	ExtraData             string
                        	StakeVersion          uint32
                        	PreviousHash          string
                        	NextHash              string
                        	TotalSent             float64
                        	MiningFee             dcrutil.Amount
                        	StakeValidationHeight int64
                        }

                          BlockInfo models data for display on the block page

                          type BlockSubsidy

                          type BlockSubsidy struct {
                          	Total int64 `json:"total"`
                          	PoW   int64 `json:"pow"`
                          	PoS   int64 `json:"pos"`
                          	Dev   int64 `json:"dev"`
                          }

                            BlockSubsidy is an implementation of dcrjson.GetBlockSubsidyResult

                            type BlockValidation

                            type BlockValidation struct {
                            	Hash     string `json:"hash"`
                            	Height   int64  `json:"height"`
                            	Validity bool   `json:"validity"`
                            }

                              BlockValidation models data about a vote's decision on a block

                              type ChainParams

                              type ChainParams struct {
                              	WindowSize       int64 `json:"window_size"`
                              	RewardWindowSize int64 `json:"reward_window_size"`
                              	TargetPoolSize   int64 `json:"target_pool_size"`
                              	BlockTime        int64 `json:"target_block_time"`
                              }

                                ChainParams models simple data about the chain server's parameters used for some info on the front page

                                type HomeInfo

                                type HomeInfo struct {
                                	CoinSupply        int64          `json:"coin_supply"`
                                	StakeDiff         float64        `json:"sdiff"`
                                	IdxBlockInWindow  int            `json:"window_idx"`
                                	IdxInRewardWindow int            `json:"reward_idx"`
                                	Difficulty        float64        `json:"difficulty"`
                                	DevFund           int64          `json:"dev_fund"`
                                	DevAddress        string         `json:"dev_address"`
                                	TicketROI         float64        `json:"roi"`
                                	ROIPeriod         string         `json:"roi_period"`
                                	NBlockSubsidy     BlockSubsidy   `json:"subsidy"`
                                	Params            ChainParams    `json:"params"`
                                	PoolInfo          TicketPoolInfo `json:"pool_info"`
                                }

                                  HomeInfo represents data used for the home page

                                  type MempoolInfo

                                  type MempoolInfo struct {
                                  	sync.RWMutex
                                  	NumTickets uint32 `json:"num_tickets"`
                                  	NumVotes   uint32 `json:"num_votes"`
                                  }

                                    MempoolInfo models data to update mempool info on the home page

                                    type TicketPoolInfo

                                    type TicketPoolInfo struct {
                                    	Size          uint32  `json:"size"`
                                    	Value         float64 `json:"value"`
                                    	ValAvg        float64 `json:"valavg"`
                                    	Percentage    float64 `json:"percent"`
                                    	Target        uint16  `json:"target"`
                                    	PercentTarget float64 `json:"percent_target"`
                                    }

                                    type TxBasic

                                    type TxBasic struct {
                                    	TxID          string
                                    	FormattedSize string
                                    	Total         float64
                                    	Fee           dcrutil.Amount
                                    	FeeRate       dcrutil.Amount
                                    	VoteInfo      *VoteInfo
                                    	Coinbase      bool
                                    }

                                      TxBasic models data for transactions on the block page

                                      type TxInID

                                      type TxInID struct {
                                      	Hash  string
                                      	Index uint32
                                      }

                                        TxInID models the identity of a spending transaction input

                                        type TxInfo

                                        type TxInfo struct {
                                        	*TxBasic
                                        	SpendingTxns    []TxInID
                                        	Type            string
                                        	Vin             []Vin
                                        	Vout            []Vout
                                        	BlockHeight     int64
                                        	BlockIndex      uint32
                                        	Confirmations   int64
                                        	Time            int64
                                        	FormattedTime   string
                                        	Mature          string
                                        	VoteFundsLocked string
                                        	TicketMaturity  int64
                                        }

                                          TxInfo models data needed for display on the tx page

                                          type Vin

                                          type Vin struct {
                                          	*dcrjson.Vin
                                          	Addresses       []string
                                          	FormattedAmount string
                                          }

                                            Vin models basic data about a tx input for display

                                            type VoteInfo

                                            type VoteInfo struct {
                                            	Validation BlockValidation         `json:"block_validation"`
                                            	Version    uint32                  `json:"vote_version"`
                                            	Bits       uint16                  `json:"vote_bits"`
                                            	Choices    []*txhelpers.VoteChoice `json:"vote_choices"`
                                            }

                                              VoteInfo models data about a SSGen transaction (vote)

                                              type Vout

                                              type Vout struct {
                                              	Addresses       []string
                                              	Amount          float64
                                              	FormattedAmount string
                                              	Type            string
                                              	Spent           bool
                                              	OP_RETURN       string
                                              }

                                                Vout models basic data about a tx output for display

                                                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 WebsocketBlock

                                                  type WebsocketBlock struct {
                                                  	Block *BlockBasic `json:"block"`
                                                  	Extra *HomeInfo   `json:"extra"`
                                                  }

                                                    WebsocketBlock wraps the new block info for use in the websocket

                                                    type WebsocketHub

                                                    type WebsocketHub struct {
                                                    	sync.RWMutex
                                                    
                                                    	Register        chan *hubSpoke
                                                    	Unregister      chan *hubSpoke
                                                    	HubRelay        chan hubSignal
                                                    	NewBlockSummary chan BlockBasic
                                                    	// 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) 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)

                                                            RegisterClient registers a websocket connection with the hub.

                                                            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.

                                                                GOOS=linux, GOARCH=amd64