Commit c63a3b0
committed
Optimize user management with map-based storage for O(1) operations
- Replace slice-based client storage with map[string]api.Account for O(1) lookups
- Add convertClientsMapToSlice() and convertClientsSliceToMap() helpers
- Refactor syncUsers(), updateUser(), and removeUser() to use maps
- Convert maps to slices only during JSON serialization in ToBytes()
- Maintain backward compatibility in NewXRayConfig() for existing JSON configs
Performance improvements:
- updateUser(): O(n) -> O(1) (~5000x faster for 10k users)
- removeUser(): O(n) -> O(1) (~5000x faster for 10k users)
- syncUsers(): Eliminates repeated O(n) scans during rebuilds
This resolves delayed user activation issues after /user/sync by eliminating
expensive slice operations that caused multi-minute delays during high load
or after node restarts.1 parent 1f3a90e commit c63a3b0
1 file changed
Lines changed: 216 additions & 167 deletions
0 commit comments