contractstaking

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StakingContractABI is the ABI of system staking contract
	StakingContractABI = `` /* 5568-byte string literal not displayed */

)

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 = staking.VoteBucket

Bucket defines the bucket struct for contract staking

type BucketType

BucketType defines the type of contract staking bucket

type ContractIndexer

type ContractIndexer interface {
	blockdao.BlockIndexerWithStart

	// CandidateVotes returns the total staked votes of a candidate
	// candidate identified by owner address
	CandidateVotes(ownerAddr address.Address) *big.Int
	// Buckets returns active buckets
	Buckets() ([]*Bucket, error)
	// BucketsByIndices returns active buckets by indices
	BucketsByIndices([]uint64) ([]*Bucket, error)
	// BucketsByCandidate returns active buckets by candidate
	BucketsByCandidate(ownerAddr address.Address) ([]*Bucket, error)
	// TotalBucketCount returns the total number of buckets including burned buckets
	TotalBucketCount() uint64
	// BucketTypes returns the active bucket types
	BucketTypes() ([]*BucketType, error)
}

ContractIndexer defines the interface of contract staking reader

func NewDummyContractStakingIndexer

func NewDummyContractStakingIndexer() ContractIndexer

NewDummyContractStakingIndexer creates an empty contract staking indexer

type Indexer

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

Indexer is the contract staking indexer Main functions:

  1. handle contract staking contract events when new block comes to generate index data
  2. provide query interface for contract staking index data

func NewContractStakingIndexer

func NewContractStakingIndexer(kvStore db.KVStore, contractAddr string, contractDeployHeight uint64) (*Indexer, error)

NewContractStakingIndexer creates a new contract staking indexer

func (*Indexer) Bucket

func (s *Indexer) Bucket(id uint64) (*Bucket, bool)

Bucket returns the bucket

func (*Indexer) BucketTypes

func (s *Indexer) BucketTypes() ([]*BucketType, error)

BucketTypes returns the active bucket types

func (*Indexer) Buckets

func (s *Indexer) Buckets() ([]*Bucket, error)

Buckets returns the buckets

func (*Indexer) BucketsByCandidate

func (s *Indexer) BucketsByCandidate(candidate address.Address) ([]*Bucket, error)

BucketsByCandidate returns the buckets by candidate

func (*Indexer) BucketsByIndices

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

BucketsByIndices returns the buckets by indices

func (*Indexer) CandidateVotes

func (s *Indexer) CandidateVotes(candidate address.Address) *big.Int

CandidateVotes returns the candidate votes

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() uint64

TotalBucketCount returns the total bucket count including active and burnt buckets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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