mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
refactor(channelserver): extract UserBinaryStore and MinidataStore
The userBinary and minidata maps with their locks were spread across Server as raw fields with manual lock management. Cross-channel session searches also required acquiring nested locks (server lock + binary lock). Encapsulating in dedicated types eliminates the nested locking and reduces Server's field count by 4.
This commit is contained in:
@@ -50,12 +50,11 @@ func TestHandleMsgSysNotifyUserBinary(t *testing.T) {
|
||||
|
||||
func TestHandleMsgSysGetUserBinary_FromCache(t *testing.T) {
|
||||
server := createMockServer()
|
||||
server.userBinaryParts = make(map[userBinaryPartID][]byte)
|
||||
server.userBinary = NewUserBinaryStore()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
// Pre-populate cache
|
||||
key := userBinaryPartID{charID: 100, index: 1}
|
||||
server.userBinaryParts[key] = []byte{0x01, 0x02, 0x03, 0x04}
|
||||
server.userBinary.Set(100, 1, []byte{0x01, 0x02, 0x03, 0x04})
|
||||
|
||||
pkt := &mhfpacket.MsgSysGetUserBinary{
|
||||
AckHandle: 12345,
|
||||
@@ -78,7 +77,7 @@ func TestHandleMsgSysGetUserBinary_FromCache(t *testing.T) {
|
||||
|
||||
func TestHandleMsgSysGetUserBinary_NotInCache(t *testing.T) {
|
||||
server := createMockServer()
|
||||
server.userBinaryParts = make(map[userBinaryPartID][]byte)
|
||||
server.userBinary = NewUserBinaryStore()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
pkt := &mhfpacket.MsgSysGetUserBinary{
|
||||
|
||||
Reference in New Issue
Block a user