Move batch struct to upstream.go

This commit is contained in:
Simon Ser 2022-05-30 09:45:40 +02:00
parent da8f626e51
commit 289a4e118a
2 changed files with 11 additions and 11 deletions

7
irc.go
View File

@ -222,13 +222,6 @@ func copyClientTags(tags irc.Tags) irc.Tags {
return t return t
} }
type batch struct {
Type string
Params []string
Outer *batch // if not-nil, this batch is nested in Outer
Label string
}
type casemapping func(string) string type casemapping func(string) string
func casemapNone(name string) string { func casemapNone(name string) string {

View File

@ -103,6 +103,13 @@ func (uc *upstreamChannel) updateAutoDetach(dur time.Duration) {
}) })
} }
type upstreamBatch struct {
Type string
Params []string
Outer *upstreamBatch // if not-nil, this batch is nested in Outer
Label string
}
type pendingUpstreamCommand struct { type pendingUpstreamCommand struct {
downstreamID uint64 downstreamID uint64
msg *irc.Message msg *irc.Message
@ -131,7 +138,7 @@ type upstreamConn struct {
modes userModes modes userModes
channels upstreamChannelCasemapMap channels upstreamChannelCasemapMap
caps xirc.CapRegistry caps xirc.CapRegistry
batches map[string]batch batches map[string]upstreamBatch
away bool away bool
account string account string
nextLabelID uint64 nextLabelID uint64
@ -250,7 +257,7 @@ func connectToUpstream(ctx context.Context, network *network) (*upstreamConn, er
user: network.user, user: network.user,
channels: upstreamChannelCasemapMap{newCasemapMap(0)}, channels: upstreamChannelCasemapMap{newCasemapMap(0)},
caps: xirc.NewCapRegistry(), caps: xirc.NewCapRegistry(),
batches: make(map[string]batch), batches: make(map[string]upstreamBatch),
serverPrefix: &irc.Prefix{Name: "*"}, serverPrefix: &irc.Prefix{Name: "*"},
availableChannelTypes: stdChannelTypes, availableChannelTypes: stdChannelTypes,
availableChannelModes: stdChannelModes, availableChannelModes: stdChannelModes,
@ -435,7 +442,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
delete(msg.Tags, "label") delete(msg.Tags, "label")
} }
var msgBatch *batch var msgBatch *upstreamBatch
if batchName, ok := msg.GetTag("batch"); ok { if batchName, ok := msg.GetTag("batch"); ok {
b, ok := uc.batches[batchName] b, ok := uc.batches[batchName]
if !ok { if !ok {
@ -882,7 +889,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
if label == "" && msgBatch != nil { if label == "" && msgBatch != nil {
label = msgBatch.Label label = msgBatch.Label
} }
uc.batches[tag] = batch{ uc.batches[tag] = upstreamBatch{
Type: batchType, Type: batchType,
Params: msg.Params[2:], Params: msg.Params[2:],
Outer: msgBatch, Outer: msgBatch,