Skip to content

Commit

Permalink
fix: fix error with get latest block (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
randyahx authored Oct 25, 2023
1 parent 4dab9b6 commit c8c7c2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,19 @@ func (e *Executor) GetBlockAndBlockResultAtHeight(height int64) (*tmtypes.Block,
func (e *Executor) GetLatestBlockHeight() (uint64, error) {
client := e.clients.GetClient()
res, err := client.GetLatestBlockHeight(context.Background())
latestHeight := uint64(res)
if err != nil {
logging.Logger.Errorf("executor failed to get latest block height, err=%s", err.Error())
return 0, err
}

latestHeight := uint64(res)
e.mtx.Lock()
e.height = latestHeight
e.mtx.Unlock()
return latestHeight, nil
}

func (e *Executor) GetCachedBlockHeight() (latestHeight uint64) {
func (e *Executor) GetCachedBlockHeight() uint64 {
e.mtx.Lock()
cachedHeight := e.height
e.mtx.Unlock()
Expand Down

0 comments on commit c8c7c2d

Please sign in to comment.