Skip to content

Commit

Permalink
Minor code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jul 10, 2024
1 parent c94e1c8 commit f94d0a1
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions zetaclient/chains/evm/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,19 +420,26 @@ func (ob *Observer) ObserverTSSReceive(ctx context.Context, startBlock, toBlock
return 0, err

Check warning on line 420 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L417-L420

Added lines #L417 - L420 were not covered by tests
}

// query incoming gas asset
for bn := startBlock; bn <= toBlock; bn++ {
var (

Check warning on line 423 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L423

Added line #L423 was not covered by tests
// post new block header (if any) to zetacore and ignore error
// TODO: consider having a independent ticker(from TSS scaning) for posting block headers
// https://github.com/zeta-chain/node/issues/1847
blockHeaderVerification, found := app.GetBlockHeaderEnabledChains(ob.Chain().ChainId)
if found && blockHeaderVerification.Enabled {
chainID = ob.Chain().ChainId
blockHeaderVerification, found = app.GetBlockHeaderEnabledChains(chainID)
shouldPostBlockHeader = found && blockHeaderVerification.Enabled
)

Check warning on line 430 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L427-L430

Added lines #L427 - L430 were not covered by tests

// query incoming gas asset
for bn := startBlock; bn <= toBlock; bn++ {
if shouldPostBlockHeader {

Check warning on line 434 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L433-L434

Added lines #L433 - L434 were not covered by tests
// post block header for supported chains
// TODO: move this logic in its own routine
// https://github.com/zeta-chain/node/issues/2204
err := ob.postBlockHeader(ctx, toBlock)
if err != nil {
ob.Logger().Inbound.Error().Err(err).Msg("error posting block header")
if err := ob.postBlockHeader(ctx, toBlock); err != nil {
ob.Logger().Inbound.
Error().Err(err).
Uint64("tss.to_block", toBlock).
Msg("error posting block header")

Check warning on line 442 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L438-L442

Added lines #L438 - L442 were not covered by tests
}
}

Expand All @@ -441,8 +448,12 @@ func (ob *Observer) ObserverTSSReceive(ctx context.Context, startBlock, toBlock
if err != nil {
ob.Logger().Inbound.Error().
Err(err).
Msgf("ObserverTSSReceive: error observing TSS received token in block %d for chain %d", bn, ob.Chain().ChainId)
return bn - 1, nil // we have to re-scan from this block next time
Int64("tss.chain_id", chainID).
Uint64("tss.block_number", bn).
Msg("ObserverTSSReceive: unable to ObserveTSSReceiveInBlock")

Check warning on line 453 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L451-L453

Added lines #L451 - L453 were not covered by tests

// we have to re-scan from this block next time
return bn - 1, nil

Check warning on line 456 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L456

Added line #L456 was not covered by tests
}
}

Expand Down

0 comments on commit f94d0a1

Please sign in to comment.