package pool

import (
	

	
	
)

// Session represents DC session.
type Session struct {
	DC      int
	AuthKey crypto.AuthKey
	Salt    int64
}

// SyncSession is synchronization helper for Session.
type SyncSession struct {
	data Session
	mux  sync.RWMutex
}

// NewSyncSession creates new SyncSession.
func ( Session) *SyncSession {
	return &SyncSession{
		data: ,
	}
}

// Store saves given Session.
func ( *SyncSession) ( Session) {
	.mux.Lock()
	.data = 
	.mux.Unlock()
}

// Migrate changes current DC and its addr, zeroes AuthKey and Salt.
func ( *SyncSession) ( int) {
	.mux.Lock()
	.data.DC = 
	.data.AuthKey = crypto.AuthKey{}
	.data.Salt = 0
	.mux.Unlock()
}

// Options fills Key and Salt field of given Options using stored session and returns it.
func ( *SyncSession) ( mtproto.Options) (mtproto.Options, Session) {
	.mux.RLock()
	 := .data
	.mux.RUnlock()

	.Key = .AuthKey
	.Salt = .Salt
	return , 
}

// Load gets session and returns it.
func ( *SyncSession) () ( Session) {
	.mux.RLock()
	 = .data
	.mux.RUnlock()

	return
}