Skip to content

Commit

Permalink
Add option to force witness start scan height
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyilong committed Oct 7, 2024
1 parent a55d527 commit 91fe83f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const (
CfgSubchainMainchainBlockIntervalInSeconds = "subchain.mainchainBlockIntervalInSeconds"
CfgSubchainMainchainWitenessStartScanHeight = "subchain.mainchainWitenessStartScanHeight"
CfgSubchainSubchainWitenessStartScanHeight = "subchain.subchainWitenessStartScanHeight"
CfgSubchainForceWitnessStartScanHeight = "subchain.forceWitenessStartScanHeight"

// CfgSubchainID defines the subchainID
CfgSubchainID = "subchain.chainID"
Expand Down Expand Up @@ -240,6 +241,7 @@ func init() {
viper.SetDefault(CfgSubchainEthRpcURL, "http://127.0.0.1:19888")
viper.SetDefault(CfgSubchainMainchainWitenessStartScanHeight, -1)
viper.SetDefault(CfgSubchainSubchainWitenessStartScanHeight, -1)
viper.SetDefault(CfgSubchainForceWitnessStartScanHeight, false)

viper.SetDefault(CfgSubchainID, 360777)
}
Expand Down
3 changes: 2 additions & 1 deletion interchain/witness/metachain_witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ func (mw *MetachainWitness) collectInterChainMessageEventsOnChain(queriedChainID
// mw.getBlockScanStartingHeight(queriedChainID) // testing code

fromBlock, err := mw.witnessState.getLastQueryedHeightForType(queriedChainID)
if err == store.ErrKeyNotFound {
forceWitnessStartScanHeight := viper.GetBool(scom.CfgSubchainForceWitnessStartScanHeight)
if forceWitnessStartScanHeight || err == store.ErrKeyNotFound {
logger.Infof("Seting the initial block scanning height for chain %v", queriedChainID.String())
if queriedChainID.Cmp(mw.mainchainID) == 0 && viper.GetInt(scom.CfgSubchainMainchainWitenessStartScanHeight) >= 0 {
// if the start scanning height is specified in the config, use the config value
Expand Down

0 comments on commit 91fe83f

Please sign in to comment.