stakingindex

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrBucketNotExist is the error when bucket does not exist
	ErrBucketNotExist = errors.New("bucket does not exist")
)

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Candidate                 address.Address
	Owner                     address.Address
	StakedAmount              *big.Int
	StakedDurationBlockNumber uint64
	CreatedAt                 uint64
	UnlockedAt                uint64
	UnstakedAt                uint64
}

func (*Bucket) Clone

func (b *Bucket) Clone() *Bucket

func (*Bucket) Deserialize

func (bi *Bucket) Deserialize(b []byte) error

Deserialize deserializes the bucket info

func (*Bucket) Serialize

func (bi *Bucket) Serialize() []byte

type Indexer

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

Indexer is the staking indexer

func NewIndexer

func NewIndexer(kvstore db.KVStore, contractAddr string, startHeight uint64, blockInterval time.Duration) *Indexer

NewIndexer creates a new staking indexer

func (*Indexer) Bucket

func (s *Indexer) Bucket(id uint64, height uint64) (*VoteBucket, bool, error)

Bucket returns the bucket

func (*Indexer) Buckets

func (s *Indexer) Buckets(height uint64) ([]*VoteBucket, error)

Buckets returns the buckets

func (*Indexer) BucketsByCandidate

func (s *Indexer) BucketsByCandidate(candidate address.Address, height uint64) ([]*VoteBucket, error)

BucketsByCandidate returns the buckets by candidate

func (*Indexer) BucketsByIndices

func (s *Indexer) BucketsByIndices(indices []uint64, height uint64) ([]*VoteBucket, error)

BucketsByIndices returns the buckets by indices

func (*Indexer) ContractAddress

func (s *Indexer) ContractAddress() string

ContractAddress returns the contract address

func (*Indexer) DeleteTipBlock

func (s *Indexer) DeleteTipBlock(context.Context, *block.Block) error

DeleteTipBlock deletes the tip block from indexer

func (*Indexer) Height

func (s *Indexer) Height() (uint64, error)

Height returns the tip block height

func (*Indexer) PutBlock

func (s *Indexer) PutBlock(ctx context.Context, blk *block.Block) error

PutBlock puts a block into indexer

func (*Indexer) Start

func (s *Indexer) Start(ctx context.Context) error

Start starts the indexer

func (*Indexer) StartHeight

func (s *Indexer) StartHeight() uint64

StartHeight returns the start height of the indexer

func (*Indexer) Stop

func (s *Indexer) Stop(ctx context.Context) error

Stop stops the indexer

func (*Indexer) TotalBucketCount

func (s *Indexer) TotalBucketCount(height uint64) (uint64, error)

TotalBucketCount returns the total bucket count including active and burnt buckets

type StakingIndexer

type StakingIndexer interface {
	lifecycle.StartStopper
	Height() (uint64, error)
	StartHeight() uint64
	ContractAddress() string
	Buckets(height uint64) ([]*VoteBucket, error)
	Bucket(id uint64, height uint64) (*VoteBucket, bool, error)
	BucketsByIndices(indices []uint64, height uint64) ([]*VoteBucket, error)
	BucketsByCandidate(candidate address.Address, height uint64) ([]*VoteBucket, error)
	TotalBucketCount(height uint64) (uint64, error)
	PutBlock(ctx context.Context, blk *block.Block) error
	DeleteTipBlock(ctx context.Context, blk *block.Block) error
}

StakingIndexer defines the interface of staking indexer

type VoteBucket

type VoteBucket = staking.VoteBucket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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