baker

package
v0.0.0-...-71505b4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToBaker

func ConvertToBaker(delegate *models.Delegate) models.Baker

func ConvertToBakers

func ConvertToBakers(delegates []models.Delegate) []models.Baker

Types

type BakerCounter

type BakerCounter struct {
	Baker string
	Count int64
}

type BakerWeightedCounter

type BakerWeightedCounter struct {
	BakerCounter
	Weight float64
}

type Repo

type Repo interface {
	Find(accountID string) (bool, models.Delegate, error)
	List(limit, offset uint) ([]models.Baker, error)
	Count(filter models.Delegate) (int64, error)
	BlocksCountBakedBy(ids []string, startingLevel int64) (counter []BakerCounter, err error)
	EndorsementsCountBy(ids []string, startingLevel int64) (counter []BakerWeightedCounter, err error)
	TotalStakingBalance() (int64, error)
}

type Repository

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

Repository is the baker repo implementation.

func New

func New(db *gorm.DB) *Repository

New creates an instance of repository using the provided db.

func (*Repository) BlocksCountBakedBy

func (r *Repository) BlocksCountBakedBy(ids []string, startingLevel int64) (counter []BakerCounter, err error)

BlocksCountBakedBy returns a slice of block counters with the number of blocks baked by each baker among ids.

func (*Repository) Count

func (r *Repository) Count(filter models.Delegate) (count int64, err error)

Count counts a number of bakers sutisfying the filter.

func (*Repository) EndorsementsCountBy

func (r *Repository) EndorsementsCountBy(ids []string, startingLevel int64) (counter []BakerWeightedCounter, err error)

BlocksCountBakedBy returns a slice of block counters with the number of endorsements made by each baker among ids.

func (*Repository) EndorsementsOperationsCountBy

func (r *Repository) EndorsementsOperationsCountBy(ids []string, startingLevel int64) (counter []BakerCounter, err error)

EndorsementsOperationsCountBy returns a slice of block counters with the number of endorsements made by each baker among ids.

func (*Repository) ExtendBakers

func (r *Repository) ExtendBakers(bakers []models.Baker) (extended []models.Baker, err error)

func (*Repository) Find

func (r *Repository) Find(accountID string) (found bool, delegate models.Delegate, err error)

func (*Repository) List

func (r *Repository) List(limit, offset uint) (bakers []models.Baker, err error)

List returns a list of bakers ordered by their staking balance. limit defines the limit for the maximum number of bakers returned, offset sets the offset for thenumber of rows returned.

func (*Repository) TotalStakingBalance

func (r *Repository) TotalStakingBalance() (b int64, err error)

TotalStakingBalance gets the total staked balance of all delegates.

Jump to

Keyboard shortcuts

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