contractstaking

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 (
	// ErrInvalidHeight is the error when height is invalid
	ErrInvalidHeight = errors.New("invalid height")
)

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 Config

type Config struct {
	ContractAddress      string // stake contract ContractAddress
	ContractDeployHeight uint64 // height of the contract deployment
	// TODO: move calculateVoteWeightFunc out of config
	CalculateVoteWeight calculateVoteWeightFunc // calculate vote weight function
	BlocksToDuration    blocksDurationAtFn      // function to calculate duration from block range
}

Config is the config for contract staking indexer

type Indexer

type Indexer struct {
	lifecycle.Readiness
	// 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, config Config) (*Indexer, error)

NewContractStakingIndexer creates a new contract staking indexer

func (*Indexer) Bucket

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

Bucket returns the bucket

func (*Indexer) BucketTypes

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

BucketTypes returns the active bucket types

func (*Indexer) Buckets

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

Buckets returns the buckets

func (*Indexer) BucketsByCandidate

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

BucketsByCandidate returns the buckets by candidate

func (*Indexer) BucketsByIndices

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

BucketsByIndices returns the buckets by indices

func (*Indexer) CandidateVotes

func (s *Indexer) CandidateVotes(ctx context.Context, candidate address.Address, height uint64) (*big.Int, error)

CandidateVotes returns the candidate votes

func (*Indexer) ContractAddress

func (s *Indexer) ContractAddress() address.Address

ContractAddress returns the contract address

func (*Indexer) ContractStakingBuckets added in v2.3.0

func (s *Indexer) ContractStakingBuckets() (uint64, map[uint64]*contractstaking.Bucket, error)

ContractStakingBuckets returns all contract staking buckets

func (*Indexer) CreateEventProcessor added in v2.3.0

func (s *Indexer) CreateEventProcessor(ctx context.Context, handler staking.EventHandler) staking.EventProcessor

CreateEventProcessor creates a new event processor for contract staking

func (*Indexer) DeductBucket added in v2.3.0

func (s *Indexer) DeductBucket(addr address.Address, id uint64) (*contractstaking.Bucket, error)

DeductBucket deducts the bucket by address and id

func (*Indexer) Height

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

Height returns the tip block height

func (*Indexer) IndexerAt added in v2.3.3

IndexerAt returns the contract staking indexer at a specific height

func (*Indexer) LoadStakeView added in v2.3.0

LoadStakeView loads the contract stake view

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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