Skip to content

Commit

Permalink
fix NaiveStrategy::UpdateClients to call Prover::CheckRefreshRequired…
Browse files Browse the repository at this point in the history
… only when no relays are needed

Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Oct 23, 2023
1 parent c710b24 commit eb9f937
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions core/naive-strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,29 +490,26 @@ func (st *NaiveStrategy) UpdateClients(src, dst *ProvableChain, rpForRecv, rpFor
MaxMsgLength: st.MaxMsgLength,
}

needsRefreshForSrc, err := src.CheckRefreshRequired(dst)
if err != nil {
return fmt.Errorf("failed to check if the LC on the src chain needs to be refreshed: %v", err)
}
needsRefreshForDst, err := dst.CheckRefreshRequired(src)
if err != nil {
return fmt.Errorf("failed to check if the LC on the dst chain needs to be refreshed: %v", err)
}

// check if unrelayed packets or acks exist
needsUpdateForSrc := needsRefreshForSrc ||
len(rpForRecv.Dst) > 0 ||
needsUpdateForSrc := len(rpForRecv.Dst) > 0 ||
!st.srcNoAck && len(rpForAck.Dst) > 0
needsUpdateForDst := needsRefreshForDst ||
len(rpForRecv.Src) > 0 ||
needsUpdateForDst := len(rpForRecv.Src) > 0 ||
!st.dstNoAck && len(rpForAck.Src) > 0

// check if LC refresh is needed
if !needsUpdateForSrc && doRefresh {
//TODO: check if LC refresh is needed for src chain
var err error
needsUpdateForSrc, err = src.CheckRefreshRequired(dst)
if err != nil {
return fmt.Errorf("failed to check if the LC on the src chain needs to be refreshed: %v", err)
}
}
if !needsUpdateForDst && doRefresh {
//TODO: check if LC refresh is needed for dst chain
var err error
needsUpdateForDst, err = dst.CheckRefreshRequired(src)
if err != nil {
return fmt.Errorf("failed to check if the LC on the dst chain needs to be refreshed: %v", err)
}
}

if needsUpdateForSrc {
Expand Down

0 comments on commit eb9f937

Please sign in to comment.