 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Variables
- type Bucket
- type Indexer
- func (s *Indexer) Bucket(id uint64, height uint64) (*VoteBucket, bool, error)
- func (s *Indexer) Buckets(height uint64) ([]*VoteBucket, error)
- func (s *Indexer) BucketsByCandidate(candidate address.Address, height uint64) ([]*VoteBucket, error)
- func (s *Indexer) BucketsByIndices(indices []uint64, height uint64) ([]*VoteBucket, error)
- func (s *Indexer) ContractAddress() string
- func (s *Indexer) Height() (uint64, 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) StartView(ctx context.Context) (staking.ContractStakeView, error)
- func (s *Indexer) Stop(ctx context.Context) error
- func (s *Indexer) TotalBucketCount(height uint64) (uint64, error)
 
- type IndexerOption
- type StakingIndexer
- type VoteBucket
Constants ¶
This section is empty.
Variables ¶
      View Source
      
  
var ( // StakingContractABI is the abi of staking contract StakingContractABI abi.ABI // 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
	// Timestamped indicates whether the bucket time is in block height or timestamp
	Timestamped bool
	// these fields value are determined by the timestamped field
	StakedDuration uint64 // in seconds if timestamped, in block number if not
	CreatedAt      uint64 // in unix timestamp if timestamped, in block height if not
	UnlockedAt     uint64 // in unix timestamp if timestamped, in block height if not
	UnstakedAt     uint64 // in unix timestamp if timestamped, in block height if not
	// Muted indicates whether the bucket is vote weight muted
	Muted bool
}
    func (*Bucket) Deserialize ¶
Deserialize deserializes the bucket info
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, blocksToDurationFn blocksDurationAtFn, opts ...IndexerOption) *Indexer
NewIndexer creates a new staking indexer
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 ¶
ContractAddress returns the contract address
func (*Indexer) StartHeight ¶
StartHeight returns the start height of the indexer
type IndexerOption ¶ added in v2.2.0
type IndexerOption func(*Indexer)
IndexerOption is the option to create an indexer
func EnableTimestamped ¶ added in v2.2.0
func EnableTimestamped() IndexerOption
EnableTimestamped enables timestamped
func WithMuteHeight ¶ added in v2.2.0
func WithMuteHeight(height uint64) IndexerOption
WithMuteHeight sets the mute height
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
	StartView(ctx context.Context) (staking.ContractStakeView, error)
}
    StakingIndexer defines the interface of staking indexer
type VoteBucket ¶
type VoteBucket = staking.VoteBucket
       Source Files
      ¶
      Source Files
      ¶
    
   Click to show internal directories. 
   Click to hide internal directories.