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

This commit is contained in:
Damian Nolan 2024-11-20 11:51:51 +01:00 committed by GitHub
parent 6351dc3a73
commit 50c5963d96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
}