Skip to content

Commit

Permalink
fix: polling running when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Apr 10, 2024
1 parent 5d86605 commit c21cd09
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 29 deletions.
3 changes: 1 addition & 2 deletions relayer/chains/evm/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, blockIn
for {
select {
case <-ctx.Done():
p.log.Debug("evm listener: context done")
p.log.Debug("evm listener: done")
return nil
case <-subscribeStart.C:
subscribeStart.Stop()
Expand Down Expand Up @@ -160,7 +160,6 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, blockIn
return
}
}
latest++
}(q)
}
}
Expand Down
26 changes: 0 additions & 26 deletions relayer/chains/icon/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package icon

import (
"bytes"
"context"
"encoding/base64"
"fmt"
Expand Down Expand Up @@ -187,14 +186,6 @@ func (c *Client) GetBlockHeaderBytesByHeight(p *types.BlockHeightParam) ([]byte,
return result, nil
}

func (c *Client) GetVotesByHeight(p *types.BlockHeightParam) ([]byte, error) {
var result []byte
if _, err := c.Do("icx_getVotesByHeight", p, &result); err != nil {
return nil, err
}
return result, nil
}

func (c *Client) GetDataByHash(p *types.DataHashParam) ([]byte, error) {
var result []byte
_, err := c.Do("icx_getDataByHash", p, &result)
Expand Down Expand Up @@ -427,23 +418,6 @@ func (c *Client) GetBlockHeaderByHeight(height int64) (*types.BlockHeader, error
return &blockHeader, nil
}

func (c *Client) GetValidatorsByHash(hash common.HexHash) ([]common.Address, error) {
data, err := c.GetDataByHash(&types.DataHashParam{Hash: types.NewHexBytes(hash.Bytes())})
if err != nil {
return nil, errors.Wrapf(err, "GetDataByHash; %v", err)
}
if !bytes.Equal(hash, crypto.SHA3Sum256(data)) {
return nil, errors.Errorf(
"invalid data: hash=%v, data=%v", hash, common.HexBytes(data))
}
var validators []common.Address
_, err = codec.BC.UnmarshalFromBytes(data, &validators)
if err != nil {
return nil, errors.Wrapf(err, "Unmarshal Validators: %v", err)
}
return validators, nil
}

func (c *Client) GetBalance(param *types.AddressParam) (*big.Int, error) {
var result types.HexInt
_, err := c.Do("icx_getBalance", param, &result)
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/wasm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, blockIn
Height: latestHeight,
})
default:
if startHeight+1 < latestHeight {
if startHeight < latestHeight {
p.logger.Debug("Query started", zap.Uint64("from-height", startHeight), zap.Uint64("to-height", latestHeight))
startHeight = p.runBlockQuery(ctx, blockInfoChan, startHeight, latestHeight)
}
Expand Down
2 changes: 2 additions & 0 deletions relayer/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,12 @@ func (r *Relayer) IsStale(routeMessage *types.RouteMessage) bool {
switch routeMessage.EventType {
case events.CallMessage:
if retryCount >= types.SpecialRetryCount {
fmt.Println("Marking stale, emit message")
routeMessage.ToggleStale()
}
case events.EmitMessage:
if retryCount%types.MaxTxRetry == 0 || retryCount >= types.MaxTxRetry {
fmt.Println("Marking stale")
routeMessage.ToggleStale()
}
}
Expand Down

0 comments on commit c21cd09

Please sign in to comment.