Skip to content

Commit f643a5b

Browse files
committed
Unexport chStopInFlight
1 parent 705a698 commit f643a5b

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

multinode/adaptor.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ type Adapter[RPC any, HEAD Head] struct {
2222
log logger.Logger
2323
rpc *RPC
2424
ctxTimeout time.Duration
25-
StateMu sync.RWMutex // protects state* fields
25+
stateMu sync.RWMutex // protects state* fields
2626
subsSliceMu sync.RWMutex
2727
subs map[Subscription]struct{}
2828

2929
latestBlock func(ctx context.Context, rpc *RPC) (HEAD, error)
3030
latestFinalizedBlock func(ctx context.Context, rpc *RPC) (HEAD, error)
3131

32-
// ChStopInFlight can be closed to immediately cancel all in-flight requests on
32+
// chStopInFlight can be closed to immediately cancel all in-flight requests on
3333
// this RpcMultiNodeAdapter. Closing and replacing should be serialized through
34-
// StateMu since it can happen on state transitions as well as RpcMultiNodeAdapter Close.
35-
ChStopInFlight chan struct{}
34+
// stateMu since it can happen on state transitions as well as RpcMultiNodeAdapter Close.
35+
chStopInFlight chan struct{}
3636

3737
chainInfoLock sync.RWMutex
3838
// intercepted values seen by callers of the rpcMultiNodeAdapter excluding health check calls. Need to ensure MultiNode provides repeatable read guarantee
@@ -54,7 +54,7 @@ func NewAdapter[RPC any, HEAD Head](
5454
latestBlock: latestBlock,
5555
latestFinalizedBlock: latestFinalizedBlock,
5656
subs: make(map[Subscription]struct{}),
57-
ChStopInFlight: make(chan struct{}),
57+
chStopInFlight: make(chan struct{}),
5858
}
5959
}
6060

@@ -146,7 +146,7 @@ func (m *Adapter[RPC, HEAD]) SubscribeToFinalizedHeads(ctx context.Context) (<-c
146146
}
147147

148148
func (m *Adapter[RPC, HEAD]) LatestBlock(ctx context.Context) (HEAD, error) {
149-
// capture ChStopInFlight to ensure we are not updating chainInfo with observations related to previous life cycle
149+
// capture chStopInFlight to ensure we are not updating chainInfo with observations related to previous life cycle
150150
ctx, cancel, chStopInFlight, rpc := m.AcquireQueryCtx(ctx, m.ctxTimeout)
151151
defer cancel()
152152

@@ -238,11 +238,11 @@ func MakeQueryCtx(ctx context.Context, ch services.StopChan, timeout time.Durati
238238
func (m *Adapter[RPC, HEAD]) AcquireQueryCtx(parentCtx context.Context, timeout time.Duration) (ctx context.Context, cancel context.CancelFunc,
239239
chStopInFlight chan struct{}, raw *RPC) {
240240
// Need to wrap in mutex because state transition can cancel and replace context
241-
m.StateMu.RLock()
242-
chStopInFlight = m.ChStopInFlight
241+
m.stateMu.RLock()
242+
chStopInFlight = m.chStopInFlight
243243
cp := *m.rpc
244244
raw = &cp
245-
m.StateMu.RUnlock()
245+
m.stateMu.RUnlock()
246246
ctx, cancel = MakeQueryCtx(parentCtx, chStopInFlight, timeout)
247247
return
248248
}
@@ -267,20 +267,20 @@ func (m *Adapter[RPC, HEAD]) UnsubscribeAllExcept(subs ...Subscription) {
267267
}
268268
}
269269

270-
// CancelInflightRequests closes and replaces the ChStopInFlight
270+
// CancelInflightRequests closes and replaces the chStopInFlight
271271
func (m *Adapter[RPC, HEAD]) CancelInflightRequests() {
272-
m.StateMu.Lock()
273-
defer m.StateMu.Unlock()
274-
close(m.ChStopInFlight)
275-
m.ChStopInFlight = make(chan struct{})
272+
m.stateMu.Lock()
273+
defer m.stateMu.Unlock()
274+
close(m.chStopInFlight)
275+
m.chStopInFlight = make(chan struct{})
276276
}
277277

278278
// GetChStopInflight provides a convenience helper that mutex wraps a
279-
// read to the ChStopInFlight
279+
// read to the chStopInFlight
280280
func (m *Adapter[RPC, HEAD]) GetChStopInflight() chan struct{} {
281-
m.StateMu.RLock()
282-
defer m.StateMu.RUnlock()
283-
return m.ChStopInFlight
281+
m.stateMu.RLock()
282+
defer m.stateMu.RUnlock()
283+
return m.chStopInFlight
284284
}
285285

286286
func (m *Adapter[RPC, HEAD]) ResetLatestChainInfo() {

multinode/adaptor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestMultiNodeClient_RegisterSubs(t *testing.T) {
169169
c.UnsubscribeAllExcept()
170170
})
171171

172-
t.Run("ChStopInFlight returns error and unsubscribes", func(t *testing.T) {
172+
t.Run("chStopInFlight returns error and unsubscribes", func(t *testing.T) {
173173
c := newTestClient(t)
174174
chStopInFlight := make(chan struct{})
175175
close(chStopInFlight)

0 commit comments

Comments
 (0)