Skip to content

Commit 70d9cf5

Browse files
committed
feat: made blocks configuratble and use the block-rpc for most cases decreasing the api usage
1 parent aa717ee commit 70d9cf5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

relayer/chains/wasm/provider.go

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type WasmProviderConfig struct {
5454
ChainID string `json:"chain-id" yaml:"chain-id"`
5555
RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"`
5656
BlockRPCAddr string `json:"block-rpc-addr" yaml:"block-rpc-addr"`
57+
BlockRPCMinDelta int `json:"block-rpc-delta" yaml:"block-rpc-delta"`
58+
BlockRPCRefreshTime int `json:"block-rpc-refresh-time" yaml:"block-rpc-refresh-time"`
5759
AccountPrefix string `json:"account-prefix" yaml:"account-prefix"`
5860
KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"`
5961
GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"`

relayer/chains/wasm/wasm_chain_processor.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,12 @@ func (ccp *WasmChainProcessor) Run(ctx context.Context, initialBlockHistory uint
286286

287287
ccp.log.Debug("Entering Wasm main query loop")
288288
if ccp.chainProvider.rangeSupport {
289-
inSyncNumBlocksThreshold = 10
289+
inSyncNumBlocksThreshold = 15
290+
defaultQueryLoopTime := 7
291+
if ccp.chainProvider.PCfg.BlockRPCRefreshTime > 0 {
292+
defaultQueryLoopTime = ccp.chainProvider.PCfg.BlockRPCRefreshTime
293+
}
294+
persistence.minQueryLoopDuration = time.Duration(defaultQueryLoopTime) * time.Second
290295
}
291296
ticker := time.NewTicker(persistence.minQueryLoopDuration)
292297
defer ticker.Stop()
@@ -461,7 +466,14 @@ func (ccp *WasmChainProcessor) queryCycle(ctx context.Context, persistence *quer
461466
var blocks []int64
462467
heighttoSync := syncUpHeight()
463468
delta := persistence.latestHeight - persistence.latestQueriedBlock
464-
if ccp.chainProvider.rangeSupport && delta > 20 {
469+
minDelta := 10
470+
if ccp.chainProvider.PCfg.BlockRPCMinDelta > 0 {
471+
minDelta = ccp.chainProvider.PCfg.BlockRPCMinDelta
472+
}
473+
if ccp.chainProvider.rangeSupport && delta > int64(minDelta) {
474+
ccp.log.Debug("Fetching range block",
475+
zap.Any("last_height", persistence.latestQueriedBlock),
476+
zap.Any("delta", delta))
465477
status, err := ccp.chainProvider.BlockRPCClient.Status(ctx)
466478
if err != nil {
467479
return nil

0 commit comments

Comments
 (0)