Introduce deliveredClientMap
Adds more semantics to map[string]string. Simplifies the complicated mapStringStringCasemapMap type.
This commit is contained in:
parent
5014673aae
commit
6e5a307dc7
@ -997,7 +997,7 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
|
|
||||||
// Fast-forward history to last message
|
// Fast-forward history to last message
|
||||||
for target, entry := range net.delivered.innerMap {
|
for target, entry := range net.delivered.innerMap {
|
||||||
delivered := entry.value.(map[string]string)
|
delivered := entry.value.(deliveredClientMap)
|
||||||
ch := net.channels.Value(target)
|
ch := net.channels.Value(target)
|
||||||
if ch != nil && ch.Detached {
|
if ch != nil && ch.Detached {
|
||||||
continue
|
continue
|
||||||
|
6
irc.go
6
irc.go
@ -600,12 +600,12 @@ func (cm *membershipsCasemapMap) Value(name string) *memberships {
|
|||||||
return entry.value.(*memberships)
|
return entry.value.(*memberships)
|
||||||
}
|
}
|
||||||
|
|
||||||
type mapStringStringCasemapMap struct{ casemapMap }
|
type deliveredCasemapMap struct{ casemapMap }
|
||||||
|
|
||||||
func (cm *mapStringStringCasemapMap) Value(name string) map[string]string {
|
func (cm *deliveredCasemapMap) Value(name string) deliveredClientMap {
|
||||||
entry, ok := cm.innerMap[cm.casemap(name)]
|
entry, ok := cm.innerMap[cm.casemap(name)]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return entry.value.(map[string]string)
|
return entry.value.(deliveredClientMap)
|
||||||
}
|
}
|
||||||
|
@ -1754,7 +1754,7 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
delivered = make(map[string]string)
|
delivered = make(deliveredClientMap)
|
||||||
uc.network.delivered.SetValue(entity, delivered)
|
uc.network.delivered.SetValue(entity, delivered)
|
||||||
|
|
||||||
for clientName, _ := range uc.network.offlineClients {
|
for clientName, _ := range uc.network.offlineClients {
|
||||||
|
8
user.go
8
user.go
@ -55,6 +55,8 @@ type eventChannelDetach struct {
|
|||||||
|
|
||||||
type eventStop struct{}
|
type eventStop struct{}
|
||||||
|
|
||||||
|
type deliveredClientMap map[string]string // client name -> msg ID
|
||||||
|
|
||||||
type network struct {
|
type network struct {
|
||||||
Network
|
Network
|
||||||
user *user
|
user *user
|
||||||
@ -62,8 +64,8 @@ type network struct {
|
|||||||
|
|
||||||
conn *upstreamConn
|
conn *upstreamConn
|
||||||
channels channelCasemapMap
|
channels channelCasemapMap
|
||||||
delivered mapStringStringCasemapMap // entity -> client name -> msg ID
|
delivered deliveredCasemapMap
|
||||||
offlineClients map[string]struct{} // indexed by client name
|
offlineClients map[string]struct{} // indexed by client name
|
||||||
lastError error
|
lastError error
|
||||||
casemap casemapping
|
casemap casemapping
|
||||||
}
|
}
|
||||||
@ -80,7 +82,7 @@ func newNetwork(user *user, record *Network, channels []Channel) *network {
|
|||||||
user: user,
|
user: user,
|
||||||
stopped: make(chan struct{}),
|
stopped: make(chan struct{}),
|
||||||
channels: m,
|
channels: m,
|
||||||
delivered: mapStringStringCasemapMap{newCasemapMap(0)},
|
delivered: deliveredCasemapMap{newCasemapMap(0)},
|
||||||
offlineClients: make(map[string]struct{}),
|
offlineClients: make(map[string]struct{}),
|
||||||
casemap: casemapRFC1459,
|
casemap: casemapRFC1459,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user