Skip to content

Commit 9bb9948

Browse files
committed
tapfreighter: rename field exportReqs to outboundParcels for clarity
This commit also adds a field doc comment.
1 parent 8a3ded6 commit 9bb9948

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

tapfreighter/chain_porter.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ type ChainPorter struct {
110110

111111
cfg *ChainPorterConfig
112112

113-
exportReqs chan Parcel
113+
// outboundParcels is a channel that carries outbound parcels that need
114+
// to be processed by the main porter goroutine.
115+
outboundParcels chan Parcel
114116

115117
// subscribers is a map of components that want to be notified on new
116118
// events, keyed by their subscription ID.
@@ -129,9 +131,9 @@ func NewChainPorter(cfg *ChainPorterConfig) *ChainPorter {
129131
map[uint64]*fn.EventReceiver[fn.Event],
130132
)
131133
return &ChainPorter{
132-
cfg: cfg,
133-
exportReqs: make(chan Parcel),
134-
subscribers: subscribers,
134+
cfg: cfg,
135+
outboundParcels: make(chan Parcel),
136+
subscribers: subscribers,
135137
ContextGuard: &fn.ContextGuard{
136138
DefaultTimeout: tapgarden.DefaultTimeout,
137139
Quit: make(chan struct{}),
@@ -151,8 +153,8 @@ func (p *ChainPorter) Start() error {
151153
go p.mainEventLoop()
152154

153155
// Identify any pending parcels that need to be resumed and add
154-
// them to the exportReqs channel so they can be processed by
155-
// the main porter goroutine.
156+
// them to the outboundParcels channel so they can be processed
157+
// by the main porter goroutine.
156158
ctx, cancel := p.WithCtxQuit()
157159
defer cancel()
158160
outboundParcels, err := p.cfg.ExportLog.PendingParcels(ctx)
@@ -172,7 +174,7 @@ func (p *ChainPorter) Start() error {
172174
// At this point the asset porter should be running.
173175
// It should therefore pick up the pending parcels from
174176
// the channel and attempt to deliver them.
175-
p.exportReqs <- NewPendingParcel(outboundParcel)
177+
p.outboundParcels <- NewPendingParcel(outboundParcel)
176178
}
177179
})
178180

@@ -211,7 +213,7 @@ func (p *ChainPorter) RequestShipment(req Parcel) (*OutboundParcel, error) {
211213
return nil, fmt.Errorf("failed to validate parcel: %w", err)
212214
}
213215

214-
if !fn.SendOrQuit(p.exportReqs, req, p.Quit) {
216+
if !fn.SendOrQuit(p.outboundParcels, req, p.Quit) {
215217
return nil, fmt.Errorf("ChainPorter shutting down")
216218
}
217219

@@ -247,16 +249,17 @@ func (p *ChainPorter) mainEventLoop() {
247249

248250
for {
249251
select {
250-
case req := <-p.exportReqs:
251-
// The request either has a destination address we want
252-
// to send to, or a send package is already initialized.
253-
sendPkg := req.pkg()
252+
case outboundParcel := <-p.outboundParcels:
253+
// The outbound parcel either has a destination address
254+
// we want to send to, or a send package is already
255+
// initialized.
256+
sendPkg := outboundParcel.pkg()
254257

255258
// Advance the state machine for this package as far as
256259
// possible in its own goroutine. The status will be
257260
// reported through the different channels of the send
258261
// package.
259-
go p.advanceState(sendPkg, req.kit())
262+
go p.advanceState(sendPkg, outboundParcel.kit())
260263

261264
case <-p.Quit:
262265
return

0 commit comments

Comments
 (0)