common

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: AGPL-3.0 Imports: 8 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 BackendInfo added in v0.3.5

type BackendInfo struct {
	BackendError    string      `json:"error,omitempty"`
	Chain           string      `json:"chain,omitempty"`
	Blocks          int         `json:"blocks,omitempty"`
	Headers         int         `json:"headers,omitempty"`
	BestBlockHash   string      `json:"bestBlockHash,omitempty"`
	Difficulty      string      `json:"difficulty,omitempty"`
	SizeOnDisk      int64       `json:"sizeOnDisk,omitempty"`
	Version         string      `json:"version,omitempty"`
	Subversion      string      `json:"subversion,omitempty"`
	ProtocolVersion string      `json:"protocolVersion,omitempty"`
	Timeoffset      float64     `json:"timeOffset,omitempty"`
	Warnings        string      `json:"warnings,omitempty"`
	Consensus       interface{} `json:"consensus,omitempty"`
}

BackendInfo is used to get information about blockchain

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"`

	BackendInfo BackendInfo `json:"-"`
	// 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) GetBackendInfo added in v0.3.5

func (is *InternalState) GetBackendInfo() BackendInfo

GetBackendInfo gets BackendInfo

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) SetBackendInfo added in v0.3.5

func (is *InternalState) SetBackendInfo(bi *BackendInfo)

SetBackendInfo sets new BackendInfo

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 JSONNumber added in v0.3.5

type JSONNumber string

JSONNumber is used instead of json.Number after upgrade to go 1.14

to handle data which can be numbers in double quotes or possibly not numbers at all

see https://github.com/golang/go/issues/37308

func (JSONNumber) Float64 added in v0.3.5

func (c JSONNumber) Float64() (float64, error)

Float64 returns JSONNumber as float64

func (JSONNumber) Int64 added in v0.3.5

func (c JSONNumber) Int64() (int64, error)

Int64 returns JSONNumber as int64

func (JSONNumber) MarshalJSON added in v0.3.5

func (c JSONNumber) MarshalJSON() ([]byte, error)

MarshalJSON marsalls JSONNumber to []byte if possible, return a number without quotes, otherwise string value in quotes empty string is treated as number 0

func (JSONNumber) String added in v0.3.5

func (c JSONNumber) String() string

func (*JSONNumber) UnmarshalJSON added in v0.3.5

func (c *JSONNumber) UnmarshalJSON(d []byte) error

UnmarshalJSON unmarshalls JSONNumber from []byte if the value is in quotes, remove them

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