packagepeermanagerimport("context"gsmsg"github.com/ipfs/go-graphsync/message"peer"github.com/libp2p/go-libp2p-peer")// PeerQueue is a process that sends messages to a peertypePeerQueueinterface{PeerProcessAddRequest(graphSyncRequestgsmsg.GraphSyncRequest)}// PeerQueueFactory provides a function that will create a PeerQueue.typePeerQueueFactoryfunc(ctxcontext.Context,ppeer.ID)PeerQueue// PeerMessageManager manages message queues for peerstypePeerMessageManagerstruct{*PeerManager}// NewMessageManager generates a new manger for sending messagesfuncNewMessageManager(ctxcontext.Context,createPeerQueuePeerQueueFactory)*PeerMessageManager{return&PeerMessageManager{PeerManager:New(ctx,func(ctxcontext.Context,ppeer.ID)PeerProcess{returncreatePeerQueue(ctx,p)}),}}// SendRequest sends the given GraphSyncRequest to the given peerfunc(pmm*PeerMessageManager)SendRequest(ppeer.ID,requestgsmsg.GraphSyncRequest){pq:=pmm.GetProcess(p).(PeerQueue)pq.AddRequest(request)}