Skip to content

Commit

Permalink
[iip-15] sgd indexer to ignore block less than start height (#3873)
Browse files Browse the repository at this point in the history
  • Loading branch information
millken authored May 30, 2023
1 parent 23645ff commit e0b129f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions blockindex/contractstaking/dummy_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ func (d *dummyContractStakingIndexer) Stop(ctx context.Context) error {
return nil
}

// StartHeight returns the start height of the indexer
func (d *dummyContractStakingIndexer) StartHeight() uint64 {
return 0
}

// Height returns the height of the indexer
func (d *dummyContractStakingIndexer) Height() (uint64, error) {
return 0, nil
Expand Down
2 changes: 1 addition & 1 deletion blockindex/contractstaking/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
type (
// ContractIndexer defines the interface of contract staking reader
ContractIndexer interface {
blockdao.BlockIndexer
blockdao.BlockIndexerWithStart

This comment has been minimized.

Copy link
@CoderZhi

CoderZhi May 30, 2023

Collaborator

delete


// CandidateVotes returns the total staked votes of a candidate
// candidate identified by owner address
Expand Down
5 changes: 4 additions & 1 deletion blockindex/sgd_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,14 @@ func (sgd *sgdRegistry) StartHeight() uint64 {

// PutBlock puts a block into SGDIndexer
func (sgd *sgdRegistry) PutBlock(ctx context.Context, blk *block.Block) error {
if blk.Height() < sgd.startHeight {
return nil
}
var (
r *action.Receipt
ok bool
b = batch.NewBatch()
)
b := batch.NewBatch()
receipts := getReceiptsFromBlock(blk)
for _, selp := range blk.Actions {
actHash, err := selp.Hash()
Expand Down

0 comments on commit e0b129f

Please sign in to comment.