Documentation
¶
Index ¶
- type PeerManagerFactory
- type Session
- type SessionFactory
- type SessionManager
- func (sm *SessionManager) CancelSessionWants(sesid uint64, wants []cid.Cid)
- func (sm *SessionManager) GetNextSessionID() uint64
- func (sm *SessionManager) NewSession(provSearchDelay, rebroadcastDelay time.Duration, ...) Session
- func (sm *SessionManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid.Cid, haves []cid.Cid, ...)
- func (sm *SessionManager) RemoveSession(sesid uint64)
- func (sm *SessionManager) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerManagerFactory ¶
type PeerManagerFactory func(id uint64) bssession.SessionPeerManager
PeerManagerFactory generates a new peer manager for a session.
type Session ¶
type Session interface {
exchange.Fetcher
ID() uint64
ReceiveFrom(peer.ID, []cid.Cid, []cid.Cid, []cid.Cid)
Close()
}
Session represents a bitswap session managed by the SessionManager. Sessions have their own lifecycle independent of request contexts and must be explicitly closed via the Close() method when no longer needed.
type SessionFactory ¶
type SessionFactory func( sm bssession.SessionManager, id uint64, sprm bssession.SessionPeerManager, sim *bssim.SessionInterestManager, pm bssession.PeerManager, bpm *bsbpm.BlockPresenceManager, notif notifications.PubSub, provSearchDelay time.Duration, rebroadcastDelay time.Duration, self peer.ID, retrievalState *retrieval.State) Session
SessionFactory generates a new session for the SessionManager to track.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager is responsible for creating, managing, and dispatching to sessions.
func New ¶
func New(sessionFactory SessionFactory, sessionInterestManager *bssim.SessionInterestManager, peerManagerFactory PeerManagerFactory, blockPresenceManager *bsbpm.BlockPresenceManager, peerManager bssession.PeerManager, notif notifications.PubSub, self peer.ID, ) *SessionManager
New creates a new SessionManager.
func (*SessionManager) CancelSessionWants ¶
func (sm *SessionManager) CancelSessionWants(sesid uint64, wants []cid.Cid)
CancelSessionWants is called when a session cancels wants because a call to GetBlocks() is cancelled
func (*SessionManager) GetNextSessionID ¶
func (sm *SessionManager) GetNextSessionID() uint64
GetNextSessionID returns the next sequential identifier for a session.
func (*SessionManager) NewSession ¶
func (sm *SessionManager) NewSession(provSearchDelay, rebroadcastDelay time.Duration, retrievalState *retrieval.State) Session
NewSession initializes a session and adds to the session manager.
The session is created with its own internal context and lifecycle management. The retrievalState parameter, if provided, will be attached to the session's internal context to enable diagnostic tracking of the retrieval process. This includes tracking provider discovery attempts, peer connections, and data retrieval phases, which is particularly useful for debugging timeout errors.
The returned Session must be closed via its Close() method when no longer needed. Note: When sessions are created via Client.NewSession(ctx), automatic cleanup via context.AfterFunc is provided.
func (*SessionManager) ReceiveFrom ¶
func (sm *SessionManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid.Cid, haves []cid.Cid, dontHaves []cid.Cid)
ReceiveFrom is called when a new message is received.
IMPORTANT: ReceiveFrom filters the given Cid slices in place, modifying their contents. If the caller needs to preserve a copy of the lists it should make a copy before calling ReceiveFrom.
func (*SessionManager) RemoveSession ¶
func (sm *SessionManager) RemoveSession(sesid uint64)
func (*SessionManager) Shutdown ¶
func (sm *SessionManager) Shutdown()