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
|
||||
for target, entry := range net.delivered.innerMap {
|
||||
delivered := entry.value.(map[string]string)
|
||||
delivered := entry.value.(deliveredClientMap)
|
||||
ch := net.channels.Value(target)
|
||||
if ch != nil && ch.Detached {
|
||||
continue
|
||||
|
6
irc.go
6
irc.go
@ -600,12 +600,12 @@ func (cm *membershipsCasemapMap) Value(name string) *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)]
|
||||
if !ok {
|
||||
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 ""
|
||||
}
|
||||
|
||||
delivered = make(map[string]string)
|
||||
delivered = make(deliveredClientMap)
|
||||
uc.network.delivered.SetValue(entity, delivered)
|
||||
|
||||
for clientName, _ := range uc.network.offlineClients {
|
||||
|
8
user.go
8
user.go
@ -55,6 +55,8 @@ type eventChannelDetach struct {
|
||||
|
||||
type eventStop struct{}
|
||||
|
||||
type deliveredClientMap map[string]string // client name -> msg ID
|
||||
|
||||
type network struct {
|
||||
Network
|
||||
user *user
|
||||
@ -62,8 +64,8 @@ type network struct {
|
||||
|
||||
conn *upstreamConn
|
||||
channels channelCasemapMap
|
||||
delivered mapStringStringCasemapMap // entity -> client name -> msg ID
|
||||
offlineClients map[string]struct{} // indexed by client name
|
||||
delivered deliveredCasemapMap
|
||||
offlineClients map[string]struct{} // indexed by client name
|
||||
lastError error
|
||||
casemap casemapping
|
||||
}
|
||||
@ -80,7 +82,7 @@ func newNetwork(user *user, record *Network, channels []Channel) *network {
|
||||
user: user,
|
||||
stopped: make(chan struct{}),
|
||||
channels: m,
|
||||
delivered: mapStringStringCasemapMap{newCasemapMap(0)},
|
||||
delivered: deliveredCasemapMap{newCasemapMap(0)},
|
||||
offlineClients: make(map[string]struct{}),
|
||||
casemap: casemapRFC1459,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user