Documentation
¶
Index ¶
- Constants
- Variables
- type Bucket
- type BucketType
- type Config
- type Indexer
- func (s *Indexer) Bucket(id uint64, height uint64) (*Bucket, bool, error)
- func (s *Indexer) BucketTypes(height uint64) ([]*BucketType, error)
- func (s *Indexer) Buckets(height uint64) ([]*Bucket, error)
- func (s *Indexer) BucketsByCandidate(candidate address.Address, height uint64) ([]*Bucket, error)
- func (s *Indexer) BucketsByIndices(indices []uint64, height uint64) ([]*Bucket, error)
- func (s *Indexer) CandidateVotes(ctx context.Context, candidate address.Address, height uint64) (*big.Int, error)
- func (s *Indexer) ContractAddress() address.Address
- func (s *Indexer) ContractStakingBuckets() (uint64, map[uint64]*contractstaking.Bucket, error)
- func (s *Indexer) CreateEventProcessor(ctx context.Context, handler staking.EventHandler) staking.EventProcessor
- func (s *Indexer) DeductBucket(addr address.Address, id uint64) (*contractstaking.Bucket, error)
- func (s *Indexer) Height() (uint64, error)
- func (s *Indexer) LoadStakeView(ctx context.Context, sr protocol.StateReader) (staking.ContractStakeView, error)
- func (s *Indexer) PutBlock(ctx context.Context, blk *block.Block) error
- func (s *Indexer) Start(ctx context.Context) error
- func (s *Indexer) StartHeight() uint64
- func (s *Indexer) Stop(ctx context.Context) error
- func (s *Indexer) TotalBucketCount(height uint64) (uint64, error)
Constants ¶
const ( // StakingContractABI is the ABI of system staking contract StakingContractABI = `` /* 5568-byte string literal not displayed */ )
Variables ¶
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 ¶
type BucketType = staking.ContractStakingBucketType
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 ¶
Indexer is the contract staking indexer Main functions:
- handle contract staking contract events when new block comes to generate index data
- provide query interface for contract staking index data
func NewContractStakingIndexer ¶
NewContractStakingIndexer creates a new contract staking indexer
func (*Indexer) BucketTypes ¶
func (s *Indexer) BucketTypes(height uint64) ([]*BucketType, error)
BucketTypes returns the active bucket types
func (*Indexer) BucketsByCandidate ¶
BucketsByCandidate returns the buckets by candidate
func (*Indexer) BucketsByIndices ¶
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 ¶
ContractAddress returns the contract address
func (*Indexer) ContractStakingBuckets ¶ added in v2.3.0
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
DeductBucket deducts the bucket by address and id
func (*Indexer) LoadStakeView ¶ added in v2.3.0
func (s *Indexer) LoadStakeView(ctx context.Context, sr protocol.StateReader) (staking.ContractStakeView, error)
LoadStakeView loads the contract stake view
func (*Indexer) StartHeight ¶
StartHeight returns the start height of the indexer