storagereader

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is a wrapper around a mongo client. This client is read-only.

func NewStorageReader

func NewStorageReader(ctx context.Context, dbURL string, dbName string) (*Reader, error)

NewStorageReader creates a new storage reader.

func (*Reader) CountAccounts

func (s *Reader) CountAccounts(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountAccounts returns the number of accounts matching the query.

func (*Reader) CountActivations

func (s *Reader) CountActivations(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountActivations returns the number of activations matching the query.

func (*Reader) CountApps

func (s *Reader) CountApps(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountApps returns the number of apps matching the query.

func (*Reader) CountBlocks

func (s *Reader) CountBlocks(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountBlocks returns the number of blocks matching the query.

func (*Reader) CountCoinbaseRewards added in v1.2.0

func (s *Reader) CountCoinbaseRewards(ctx context.Context, coinbase string) (total, count int64, err error)

CountCoinbaseRewards returns the number of rewards for given coinbase address.

func (*Reader) CountEpochSmeshers added in v1.3.2

func (s *Reader) CountEpochSmeshers(ctx context.Context, query *bson.D) (int64, error)

GetEpochSmeshers returns the smeshers for specific epoch

func (*Reader) CountEpochs

func (s *Reader) CountEpochs(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountEpochs returns the number of epochs matching the query.

func (*Reader) CountLayers

func (s *Reader) CountLayers(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountLayers returns the number of layers matching the query.

func (*Reader) CountReceivedTransactions added in v1.2.0

func (s *Reader) CountReceivedTransactions(ctx context.Context, address string) (amount, count int64, err error)

func (*Reader) CountRewards

func (s *Reader) CountRewards(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountRewards returns the number of rewards matching the query.

func (*Reader) CountSentTransactions added in v1.2.0

func (s *Reader) CountSentTransactions(ctx context.Context, address string) (amount, fees, count int64, err error)

func (*Reader) CountSmesherRewards

func (s *Reader) CountSmesherRewards(ctx context.Context, smesherID string) (total, count int64, err error)

CountSmesherRewards returns the number of smesher rewards matching the query.

func (*Reader) CountSmeshers

func (s *Reader) CountSmeshers(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountSmeshers returns the number of smeshers matching the query.

func (*Reader) CountTransactions

func (s *Reader) CountTransactions(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)

CountTransactions returns the number of transactions matching the query.

func (*Reader) GetAccountSummary

func (s *Reader) GetAccountSummary(ctx context.Context, address string) (*model.AccountSummary, error)

GetAccountSummary returns the summary of the accounts matching the query. Not all accounts from api have filled this data.

func (*Reader) GetAccounts

func (s *Reader) GetAccounts(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Account, error)

GetAccounts returns the accounts matching the query.

func (*Reader) GetActivations

func (s *Reader) GetActivations(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Activation, error)

GetActivations returns the activations matching the query.

func (*Reader) GetApps

func (s *Reader) GetApps(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.App, error)

GetApps returns the apps matching the query.

func (*Reader) GetBlocks

func (s *Reader) GetBlocks(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Block, error)

GetBlocks returns the blocks matching the query.

func (*Reader) GetEpoch

func (s *Reader) GetEpoch(ctx context.Context, epochNumber int) (*model.Epoch, error)

GetEpoch returns the epoch matching the query.

func (*Reader) GetEpochSmeshers added in v1.3.2

func (s *Reader) GetEpochSmeshers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Smesher, error)

GetEpochSmeshers returns the smeshers for specific epoch

func (*Reader) GetEpochs

func (s *Reader) GetEpochs(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Epoch, error)

GetEpochs returns the epochs matching the query.

func (*Reader) GetFirstSentTransaction added in v1.2.0

func (s *Reader) GetFirstSentTransaction(ctx context.Context, address string) (*model.Transaction, error)

GetFirstSentTransaction returns the first sent tx for given address

func (*Reader) GetLatestReward added in v1.2.0

func (s *Reader) GetLatestReward(ctx context.Context, coinbase string) (*model.Reward, error)

GetLatestReward returns the latest reward for given coinbase

func (*Reader) GetLatestTransaction added in v1.2.0

func (s *Reader) GetLatestTransaction(ctx context.Context, address string) (*model.Transaction, error)

GetLatestTransaction returns the latest tx for given address

func (*Reader) GetLayer

func (s *Reader) GetLayer(ctx context.Context, layerNumber int) (*model.Layer, error)

GetLayer returns the layer matching the query.

func (*Reader) GetLayerTimestamp added in v0.0.13

func (s *Reader) GetLayerTimestamp(layer uint32) uint32

func (*Reader) GetLayers

func (s *Reader) GetLayers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Layer, error)

GetLayers returns the layers matching the query.

func (*Reader) GetNetworkInfo

func (s *Reader) GetNetworkInfo(ctx context.Context) (*model.NetworkInfo, error)

GetNetworkInfo returns the network info matching the query.

func (*Reader) GetReward

func (s *Reader) GetReward(ctx context.Context, rewardID string) (*model.Reward, error)

GetReward returns the reward matching the query.

func (*Reader) GetRewardV2 added in v1.6.7

func (s *Reader) GetRewardV2(ctx context.Context, smesherID string, layer uint32) (*model.Reward, error)

func (*Reader) GetRewards

func (s *Reader) GetRewards(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Reward, error)

GetRewards returns the rewards matching the query.

func (*Reader) GetSmesher

func (s *Reader) GetSmesher(ctx context.Context, smesherID string) (*model.Smesher, error)

GetSmesher returns the smesher matching the query.

func (*Reader) GetSmeshers

func (s *Reader) GetSmeshers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Smesher, error)

GetSmeshers returns the smeshers matching the query.

func (*Reader) GetTotalRewards added in v1.2.0

func (s *Reader) GetTotalRewards(ctx context.Context, filter *bson.D) (total, count int64, err error)

GetTotalRewards returns the total number of rewards.

func (*Reader) GetTransactions

func (s *Reader) GetTransactions(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Transaction, error)

GetTransactions returns the transactions matching the query.

func (*Reader) Ping

func (s *Reader) Ping(ctx context.Context) error

Ping checks if the database is reachable.

type StorageReader

type StorageReader interface {
	Ping(ctx context.Context) error
	GetNetworkInfo(ctx context.Context) (*model.NetworkInfo, error)

	CountTransactions(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetTransactions(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Transaction, error)
	CountSentTransactions(ctx context.Context, address string) (amount, fees, count int64, err error)
	CountReceivedTransactions(ctx context.Context, address string) (amount, count int64, err error)
	GetLatestTransaction(ctx context.Context, address string) (*model.Transaction, error)
	GetFirstSentTransaction(ctx context.Context, address string) (*model.Transaction, error)

	CountApps(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetApps(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.App, error)

	CountAccounts(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetAccounts(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Account, error)
	GetAccountSummary(ctx context.Context, address string) (*model.AccountSummary, error)

	CountActivations(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetActivations(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Activation, error)

	CountBlocks(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetBlocks(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Block, error)

	CountEpochs(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetEpochs(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Epoch, error)
	GetEpoch(ctx context.Context, epochNumber int) (*model.Epoch, error)

	CountLayers(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetLayers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Layer, error)
	GetLayer(ctx context.Context, layerNumber int) (*model.Layer, error)

	CountRewards(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	CountCoinbaseRewards(ctx context.Context, coinbase string) (total, count int64, err error)
	GetRewards(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Reward, error)
	GetReward(ctx context.Context, rewardID string) (*model.Reward, error)
	GetRewardV2(ctx context.Context, smesherID string, layer uint32) (*model.Reward, error)
	GetLatestReward(ctx context.Context, coinbase string) (*model.Reward, error)
	GetTotalRewards(ctx context.Context, filter *bson.D) (total, count int64, err error)

	CountSmeshers(ctx context.Context, query *bson.D, opts ...*options.CountOptions) (int64, error)
	GetSmeshers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Smesher, error)
	GetSmesher(ctx context.Context, smesherID string) (*model.Smesher, error)
	CountEpochSmeshers(ctx context.Context, query *bson.D) (int64, error)
	GetEpochSmeshers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*model.Smesher, error)
	CountSmesherRewards(ctx context.Context, smesherID string) (total, count int64, err error)
}

StorageReader is the interface for the storage reader. Providing ReadOnly methods.

Jump to

Keyboard shortcuts

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