Skip to content

Commit b5fad15

Browse files
committed
dats gey
1 parent e39d07a commit b5fad15

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

telegram/client.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ func (e *exSenders) setTTL() {
5959
// Client is the main struct of the library
6060
type Client struct {
6161
*mtproto.MTProto
62-
Cache *CACHE
63-
clientData clientData
64-
dispatcher *UpdateDispatcher
65-
wg sync.WaitGroup
66-
stopCh chan struct{}
67-
exSenders *exSenders
68-
Log *utils.Logger
62+
Cache *CACHE
63+
clientData clientData
64+
dispatcher *UpdateDispatcher
65+
wg sync.WaitGroup
66+
stopCh chan struct{}
67+
exSenders *exSenders
68+
exportedKeys map[int]*ExportedAuthParams
69+
Log *utils.Logger
6970
}
7071

7172
type DeviceConfig struct {

telegram/media.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -695,15 +695,25 @@ func initializeWorkers(numWorkers int, dc int32, c *Client, w *WorkerPool) {
695695

696696
var authParams = ExportedAuthParams{}
697697
if dc != int32(c.GetDC()) {
698-
auth, err := c.AuthExportAuthorization(dc)
699-
if err != nil {
700-
c.Log.Error(err)
701-
return
698+
if c.exportedKeys == nil {
699+
c.exportedKeys = make(map[int]*ExportedAuthParams)
702700
}
703701

704-
authParams = ExportedAuthParams{
705-
ID: auth.ID,
706-
Bytes: auth.Bytes,
702+
if exportedKey, ok := c.exportedKeys[int(dc)]; ok {
703+
authParams = *exportedKey
704+
} else {
705+
auth, err := c.AuthExportAuthorization(dc)
706+
if err != nil {
707+
c.Log.Error(err)
708+
return
709+
}
710+
711+
authParams = ExportedAuthParams{
712+
ID: auth.ID,
713+
Bytes: auth.Bytes,
714+
}
715+
716+
c.exportedKeys[int(dc)] = &authParams
707717
}
708718
}
709719

0 commit comments

Comments
 (0)