fix: only overwrite context chainID when necessary (backport #22568) (#22569)

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
This commit is contained in:
mergify[bot]
2024-11-20 12:05:56 +01:00
committed by GitHub
co-authored by Damian Nolan
parent 088c8d1967
commit 756d4bbaf1
+5 -1
View File
@@ -2,6 +2,7 @@ package types
import (
"context"
"strings"
"time"
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
@@ -162,7 +163,10 @@ func (c Context) WithBlockHeader(header cmtproto.Header) Context {
c.header = header
// when calling withBlockheader on a new context, chainID in the struct will be empty
c.chainID = header.ChainID
if strings.TrimSpace(c.chainID) == "" {
c.chainID = header.ChainID
}
return c
}