Skip to content

Commit

Permalink
Merge f5d59fe into c91dd5e
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie committed Jul 1, 2023
2 parents c91dd5e + f5d59fe commit bf7953c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions chainservice/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,33 +285,33 @@ func (builder *Builder) buildSGDRegistry(forTest bool) error {
if builder.cs.sgdIndexer != nil {
return nil
}
if forTest {
if forTest || builder.cfg.Genesis.SystemSGDContractAddress == "" {
builder.cs.sgdIndexer = nil
} else {
kvStore, err := db.CreateKVStoreWithCache(builder.cfg.DB, builder.cfg.Chain.SGDIndexDBPath, 1000)
if err != nil {
return err
}
builder.cs.sgdIndexer = blockindex.NewSGDRegistry(builder.cfg.Genesis.SystemSGDContractAddress, builder.cfg.Genesis.SystemSGDContractHeight, kvStore)
return nil
}
kvStore, err := db.CreateKVStoreWithCache(builder.cfg.DB, builder.cfg.Chain.SGDIndexDBPath, 1000)
if err != nil {
return err
}
builder.cs.sgdIndexer = blockindex.NewSGDRegistry(builder.cfg.Genesis.SystemSGDContractAddress, builder.cfg.Genesis.SystemSGDContractHeight, kvStore)
return nil
}

func (builder *Builder) buildContractStakingIndexer(forTest bool) error {
if builder.cs.contractStakingIndexer != nil {
return nil
}
if forTest {
if forTest || builder.cfg.Genesis.SystemStakingContractAddress == "" {
builder.cs.contractStakingIndexer = contractstaking.NewDummyContractStakingIndexer()
} else {
dbConfig := builder.cfg.DB
dbConfig.DbPath = builder.cfg.Chain.ContractStakingIndexDBPath
indexer, err := contractstaking.NewContractStakingIndexer(db.NewBoltDB(dbConfig), builder.cfg.Genesis.SystemStakingContractAddress, builder.cfg.Genesis.SystemStakingContractHeight)
if err != nil {
return err
}
builder.cs.contractStakingIndexer = indexer
return nil
}
dbConfig := builder.cfg.DB
dbConfig.DbPath = builder.cfg.Chain.ContractStakingIndexDBPath
indexer, err := contractstaking.NewContractStakingIndexer(db.NewBoltDB(dbConfig), builder.cfg.Genesis.SystemStakingContractAddress, builder.cfg.Genesis.SystemStakingContractHeight)
if err != nil {
return err
}
builder.cs.contractStakingIndexer = indexer
return nil
}

Expand Down

0 comments on commit bf7953c

Please sign in to comment.