common

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DbStateClosed means db was closed gracefully
	DbStateClosed = uint32(iota)
	// DbStateOpen means db is open or application died without closing the db
	DbStateOpen
	// DbStateInconsistent means db is in inconsistent state and cannot be used
	DbStateInconsistent
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InternalState

type InternalState struct {
	Coin         string `json:"coin"`
	CoinShortcut string `json:"coinShortcut"`
	CoinLabel    string `json:"coinLabel"`
	Host         string `json:"host"`

	DbState uint32 `json:"dbState"`

	LastStore time.Time `json:"lastStore"`

	// true if application is with flag --sync
	SyncMode bool `json:"syncMode"`

	InitialSync    bool      `json:"initialSync"`
	IsSynchronized bool      `json:"isSynchronized"`
	BestHeight     uint32    `json:"bestHeight"`
	LastSync       time.Time `json:"lastSync"`
	BlockTimes     []uint32  `json:"-"`

	IsMempoolSynchronized bool      `json:"isMempoolSynchronized"`
	MempoolSize           int       `json:"mempoolSize"`
	LastMempoolSync       time.Time `json:"lastMempoolSync"`

	DbColumns []InternalStateColumn `json:"dbColumns"`

	UtxoChecked bool `json:"utxoChecked"`
	// contains filtered or unexported fields
}

InternalState contains the data of the internal state

func UnpackInternalState

func UnpackInternalState(buf []byte) (*InternalState, error)

UnpackInternalState unmarshals internal state from json

func (*InternalState) AddDBColumnStats

func (is *InternalState) AddDBColumnStats(c int, rowsDiff int64, keyBytesDiff int64, valueBytesDiff int64)

AddDBColumnStats adds differences in column statistics to column stats

func (*InternalState) AppendBlockTime added in v0.3.2

func (is *InternalState) AppendBlockTime(time uint32)

AppendBlockTime appends block time to BlockTimes

func (*InternalState) DBSizeTotal

func (is *InternalState) DBSizeTotal() int64

DBSizeTotal sums the computed sizes of all columns

func (*InternalState) FinishedMempoolSync

func (is *InternalState) FinishedMempoolSync(mempoolSize int)

FinishedMempoolSync marks end of mempool synchronization

func (*InternalState) FinishedSync

func (is *InternalState) FinishedSync(bestHeight uint32)

FinishedSync marks end of synchronization, bestHeight specifies new best block height

func (*InternalState) FinishedSyncNoChange

func (is *InternalState) FinishedSyncNoChange()

FinishedSyncNoChange marks end of synchronization in case no index update was necessary, it does not update lastSync time

func (*InternalState) GetAllDBColumnStats

func (is *InternalState) GetAllDBColumnStats() []InternalStateColumn

GetAllDBColumnStats returns stats for all columns

func (*InternalState) GetBlockHeightOfTime added in v0.3.2

func (is *InternalState) GetBlockHeightOfTime(time uint32) uint32

GetBlockHeightOfTime returns block height of the first block with time greater or equal to the given time or MaxUint32 if no such block

func (*InternalState) GetBlockTime added in v0.3.2

func (is *InternalState) GetBlockTime(height uint32) uint32

GetBlockTime returns block time if block found or 0

func (*InternalState) GetDBColumnStatValues

func (is *InternalState) GetDBColumnStatValues(c int) (int64, int64, int64)

GetDBColumnStatValues gets stat values for given column

func (*InternalState) GetMempoolSyncState

func (is *InternalState) GetMempoolSyncState() (bool, time.Time, int)

GetMempoolSyncState gets the state of mempool synchronization

func (*InternalState) GetSyncState

func (is *InternalState) GetSyncState() (bool, uint32, time.Time)

GetSyncState gets the state of synchronization

func (*InternalState) Pack

func (is *InternalState) Pack() ([]byte, error)

Pack marshals internal state to json

func (*InternalState) RemoveLastBlockTimes added in v0.3.2

func (is *InternalState) RemoveLastBlockTimes(count int)

RemoveLastBlockTimes removes last times from BlockTimes

func (*InternalState) SetDBColumnStats

func (is *InternalState) SetDBColumnStats(c int, rows int64, keyBytes int64, valueBytes int64)

SetDBColumnStats sets new values of column stats

func (*InternalState) StartedMempoolSync

func (is *InternalState) StartedMempoolSync()

StartedMempoolSync signals start of mempool synchronization

func (*InternalState) StartedSync

func (is *InternalState) StartedSync()

StartedSync signals start of synchronization

func (*InternalState) UpdateBestHeight added in v0.1.0

func (is *InternalState) UpdateBestHeight(bestHeight uint32)

UpdateBestHeight sets new best height, without changing IsSynchronized flag

type InternalStateColumn

type InternalStateColumn struct {
	Name       string    `json:"name"`
	Version    uint32    `json:"version"`
	Rows       int64     `json:"rows"`
	KeyBytes   int64     `json:"keyBytes"`
	ValueBytes int64     `json:"valueBytes"`
	Updated    time.Time `json:"updated"`
}

InternalStateColumn contains the data of a db column

type Labels

type Labels = prometheus.Labels

Labels represents a collection of label name -> value mappings.

type Metrics

type Metrics struct {
	SocketIORequests      *prometheus.CounterVec
	SocketIOSubscribes    *prometheus.CounterVec
	SocketIOClients       prometheus.Gauge
	SocketIOReqDuration   *prometheus.HistogramVec
	WebsocketRequests     *prometheus.CounterVec
	WebsocketSubscribes   *prometheus.CounterVec
	WebsocketClients      prometheus.Gauge
	WebsocketReqDuration  *prometheus.HistogramVec
	IndexResyncDuration   prometheus.Histogram
	MempoolResyncDuration prometheus.Histogram
	TxCacheEfficiency     *prometheus.CounterVec
	RPCLatency            *prometheus.HistogramVec
	IndexResyncErrors     *prometheus.CounterVec
	IndexDBSize           prometheus.Gauge
	ExplorerViews         *prometheus.CounterVec
	MempoolSize           prometheus.Gauge
	DbColumnRows          *prometheus.GaugeVec
	DbColumnSize          *prometheus.GaugeVec
	BlockbookAppInfo      *prometheus.GaugeVec
}

Metrics holds prometheus collectors for various metrics collected by Blockbook

func GetMetrics

func GetMetrics(coin string) (*Metrics, error)

GetMetrics returns struct holding prometheus collectors for various metrics collected by Blockbook

type VersionInfo

type VersionInfo struct {
	Version   string `json:"version"`
	GitCommit string `json:"gitcommit"`
	BuildTime string `json:"buildtime"`
	GoVersion string `json:"goversion"`
	OSArch    string `json:"os/arch"`
}

VersionInfo holds information about the running Blockbook instance

func GetVersionInfo

func GetVersionInfo() VersionInfo

GetVersionInfo returns VersionInfo of the running Blockbook instance

Jump to

Keyboard shortcuts

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