indexer

package
v1.0.96 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBodyTypeAssertion = errors.New("elasticsearch - body type assertion failed")

ErrBodyTypeAssertion signals that we could not create an elasticsearch index

View Source
var ErrCannotCreateIndex = errors.New("cannot create elasitc index")

ErrCannotCreateIndex signals that we could not create an elasticsearch index

View Source
var ErrEmptyPassword = errors.New("password is empty")

ErrEmptyPassword signals that password for elastic search is empty

View Source
var ErrEmptyUserName = errors.New("user name is empty")

ErrEmptyUserName signals that user name for elastic search is empty

View Source
var ErrNoHeader = errors.New("elasticsearch - no header")

ErrNoHeader signals that we could not create an elasticsearch index

View Source
var ErrNoMiniblocks = errors.New("elasticsearch - no miniblocks")

ErrNoMiniblocks signals that we could not create an elasticsearch index

Functions

This section is empty.

Types

type Block

type Block struct {
	Nonce         uint64        `json:"nonce"`
	Round         uint64        `json:"round"`
	Hash          string        `json:"hash"`
	Proposer      uint64        `json:"proposer"`
	Validators    []uint64      `json:"validators"`
	PubKeyBitmap  string        `json:"pubKeyBitmap"`
	Size          int64         `json:"size"`
	Timestamp     time.Duration `json:"timestamp"`
	StateRootHash string        `json:"stateRootHash"`
	PrevHash      string        `json:"prevHash"`
	ShardID       uint32        `json:"shardId"`
	TxCount       uint32        `json:"txCount"`
}

Block is a structure containing all the fields that need

to be saved for a block. It has all the default fields
plus some extra information for ease of search and filter

type ElasticIndexerArgs

type ElasticIndexerArgs struct {
	Url              string
	UserName         string
	Password         string
	ShardCoordinator sharding.Coordinator
	Marshalizer      marshal.Marshalizer
	Hasher           hashing.Hasher
	Options          *Options
}

ElasticIndexerArgs is struct that is used to store all components that are needed to create a indexer

type Indexer

type Indexer interface {
	SaveBlock(body data.BodyHandler, header data.HeaderHandler, txPool map[string]data.TransactionHandler, signersIndexes []uint64)
	SaveMetaBlock(header data.HeaderHandler, signersIndexes []uint64)
	SaveRoundInfo(roundInfo RoundInfo)
	UpdateTPS(tpsBenchmark statistics.TPSBenchmark)
	SaveValidatorsPubKeys(validatorsPubKeys map[uint32][][]byte)
	IsInterfaceNil() bool
	IsNilIndexer() bool
}

Indexer is an interface for saving node specific data to other storage. This could be an elastic search index, a MySql database or any other external services.

func NewElasticIndexer

func NewElasticIndexer(arguments ElasticIndexerArgs) (Indexer, error)

NewElasticIndexer creates a new elasticIndexer where the server listens on the url, authentication for the server is using the username and password

type NilIndexer

type NilIndexer struct {
}

NilIndexer will be used when an Indexer is required, but another one isn't necessary or available

func NewNilIndexer

func NewNilIndexer() *NilIndexer

NewNilIndexer will return a Nil indexer

func (*NilIndexer) IsInterfaceNil

func (ni *NilIndexer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*NilIndexer) IsNilIndexer

func (ni *NilIndexer) IsNilIndexer() bool

IsNilIndexer will return a bool value that signals if the indexer's implementation is a NilIndexer

func (*NilIndexer) SaveBlock

func (ni *NilIndexer) SaveBlock(body data.BodyHandler, header data.HeaderHandler, txPool map[string]data.TransactionHandler, signersIndexes []uint64)

SaveBlock will do nothing

func (*NilIndexer) SaveMetaBlock

func (ni *NilIndexer) SaveMetaBlock(header data.HeaderHandler, signersIndexes []uint64)

SaveMetaBlock will do nothing

func (*NilIndexer) SaveRoundInfo

func (ni *NilIndexer) SaveRoundInfo(info RoundInfo)

SaveRoundInfo will do nothing

func (*NilIndexer) SaveValidatorsPubKeys

func (ni *NilIndexer) SaveValidatorsPubKeys(validatorsPubKeys map[uint32][][]byte)

SaveValidatorsPubKeys will do nothing

func (*NilIndexer) UpdateTPS

func (ni *NilIndexer) UpdateTPS(tpsBenchmark statistics.TPSBenchmark)

UpdateTPS will do nothing

type Options

type Options struct {
	TxIndexingEnabled bool
}

Options structure holds the indexer's configuration options

type RoundInfo

type RoundInfo struct {
	Index            uint64        `json:"-"`
	SignersIndexes   []uint64      `json:"signersIndexes"`
	BlockWasProposed bool          `json:"blockWasProposed"`
	ShardId          uint32        `json:"shardId"`
	Timestamp        time.Duration `json:"timestamp"`
}

RoundInfo is a structure containing block signers and shard id

type TPS

type TPS struct {
	LiveTPS               float64  `json:"liveTPS"`
	PeakTPS               float64  `json:"peakTPS"`
	BlockNumber           uint64   `json:"blockNumber"`
	RoundNumber           uint64   `json:"roundNumber"`
	RoundTime             uint64   `json:"roundTime"`
	AverageBlockTxCount   *big.Int `json:"averageBlockTxCount"`
	TotalProcessedTxCount *big.Int `json:"totalProcessedTxCount"`
	AverageTPS            *big.Int `json:"averageTPS"`
	CurrentBlockNonce     uint64   `json:"currentBlockNonce"`
	NrOfShards            uint32   `json:"nrOfShards"`
	NrOfNodes             uint32   `json:"nrOfNodes"`
	LastBlockTxCount      uint32   `json:"lastBlockTxCount"`
	ShardID               uint32   `json:"shardID"`
}

TPS is a structure containing all the fields that need to

be saved for a shard statistic in the database

type Transaction

type Transaction struct {
	Hash          string        `json:"hash"`
	MBHash        string        `json:"miniBlockHash"`
	BlockHash     string        `json:"blockHash"`
	Nonce         uint64        `json:"nonce"`
	Round         uint64        `json:"round"`
	Value         string        `json:"value"`
	Receiver      string        `json:"receiver"`
	Sender        string        `json:"sender"`
	ReceiverShard uint32        `json:"receiverShard"`
	SenderShard   uint32        `json:"senderShard"`
	GasPrice      uint64        `json:"gasPrice"`
	GasLimit      uint64        `json:"gasLimit"`
	Data          []byte        `json:"data"`
	Signature     string        `json:"signature"`
	Timestamp     time.Duration `json:"timestamp"`
	Status        string        `json:"status"`
}

Transaction is a structure containing all the fields that need

to be saved for a transaction. It has all the default fields
plus some extra information for ease of search and filter

type ValidatorsPublicKeys

type ValidatorsPublicKeys struct {
	PublicKeys []string `json:"publicKeys"`
}

ValidatorsPublicKeys is a structure containing fields for validators public keys

Jump to

Keyboard shortcuts

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