Skip to content

Commit aa35233

Browse files
committed
lint(evm): waive containedctx where an interface forces the field
#2180 enabled containedctx and fixed the ttx occurrence. The evm module is a separate Go module and was not linted in that pass, so make lint has been failing on it since. Neither field can be dropped. Ledger.ctx exists because driver.GetStateFnc passes no context to GetState, and fakeContext.ctx exists because it implements view.Context, whose Context() method has to return one. Signed-off-by: atharrva01 <atharvaborade568@gmail.com>
1 parent 32febf4 commit aa35233

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

x/token/services/network/evm/endorsement/fakes_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ func (s *pipeSession) Close() {}
6969
// own session via Session. Everything the endorsement views do not touch panics, so an unexpected
7070
// dependency surfaces loudly rather than silently.
7171
type fakeContext struct {
72-
ctx context.Context
72+
// view.Context is an interface whose Context() method returns one, so an implementation of it has
73+
// to hold a context.
74+
ctx context.Context //nolint:containedctx
7375
me view.Identity
7476
sessions map[string]view.Session // keyed by party UniqueID, for GetSession (initiator side)
7577
own view.Session // for Session() (responder side)

x/token/services/network/evm/endorsement/ledger.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const getTokenMethod = "getToken(bytes32)" // #nosec G101 -- ABI method signatur
3434
// Ledger satisfies token.Ledger, so it can be passed straight to
3535
// Validator.UnmarshallAndVerifyWithMetadata.
3636
type Ledger struct {
37-
ctx context.Context
37+
// GetState takes no context (driver.GetStateFnc has none), so the one to read the chain with is
38+
// captured here. A Ledger is built per request and used only for it, so it stays short-lived.
39+
ctx context.Context //nolint:containedctx
3840
client client.EVMClient
3941
tokenState client.Address
4042
blockTag string

0 commit comments

Comments
 (0)