@startuml "GraphSync" package "go-ipld-prime" { interface Node { } interface NodeBuilder { } interface Path { } interface Link package traversal { package selector { interface Selector { } object "PackagePublicFunctions" as goSelectorPF { ReifySelector(cidRootedSelector Node) (Selector, error) } } interface AdvVisitFn { } class TraversalConfig { } class TraversalProgress { TraverseInformatively(Node, Selector, AdvVisitFn) } TraversalProgress *-- TraversalConfig } interface Loader { } } package "go-graphsync" { class ResponseProgress { Node ipld.Node Path ipld.Path LastBlock struct { ipld.Node ipld.Link } } interface Cid2BlockFn { } class GraphSync { Request(ctx context.Context, p peer.ID, rootedSelector Node) (chan ResponseProgress, chan error) GetBlocks(ctx context.Context, p peer.ID, rootedSelector Node) (chan blocks.Block, chan error) ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage) ReceiveError(error) } GraphSync *-- RawLoader package network { interface Receiver { ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage) ReceiveError(error) } interface GraphSyncNetwork { SendMessage(ctx context.Context, receiver peer.Id, m GraphSyncMessage) SetDelegate(receiver Receiver) ConnectTo(ctx context.Context, peer.ID) error NewMessageSender(context.Context, peer.ID) (MessageSender, error) } interface MessageSender { SendMsg(context.Context, GraphSyncMessage) error Close() error Reset() error } Receiver <|-- GraphSync : receiver for class libP2PGraphSyncNetwork { } GraphSyncNetwork <|-- libP2PGraphSyncNetwork object "Package Public Functions" as goGraphSyncNetworkPF { NewLibP2PNetwork(host libp2pHost.Host) GraphSyncNetwork } goGraphSyncNetworkPF .. libP2PGraphSyncNetwork } package messagequeue { class MessageQueue { AddRequest(GraphSyncRequest) Cancel(GraphSyncRequestID) Startup() Shutdown() } object "PackagePublicFunctions" as goMessageQueuePF { New(context.Context, peer.ID, GraphSyncNetwork) *MessageQueue } GraphSync .. goMessageQueuePF MessageQueue *-- GraphSyncNetwork } package peerhandler { class PeerManager { Connected(p peer.ID) Disconnected(p peer.ID) ConnectedPeers() []peer.ID SendRequest(peer.ID, GraphSyncRequest) } object "Package Public Functions" as goPeerManagerPF { New(ctx context.Context, createPeerQueue func(context, peer.ID) MessageQueue) } GraphSync .. goPeerManagerPF PeerManager *-- MessageQueue } package requestmanager { interface ResponseProgress { } interface ResponseError { } class RequestManager { SetDelegate(peerHandler PeerManager) SendRequest(ctx context.Context, p peer.ID, cidRootedSelector Node) chan Block ProcessResponses(message GraphSyncMessage) } RequestManager *-- PeerManager GraphSync *-- RequestManager } package responsemanager { class ResponseManager { ProcessRequests(p peer.ID, requests []GraphSyncRequests) } ResponseManager *-- GraphSyncNetwork GraphSync *-- ResponseManager ResponseManager *-- RawLoader } package message { object "Package Public Functions" as goGraphSyncMessagePF { func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error) func FromNet(r io.Reader) (GraphSyncMessage, error) } goGraphSyncMessagePF .. libP2PGraphSyncNetwork interface GraphSyncRequest { Selector() []bytes Priority() Priority ID() int IsCancel() bool } interface GraphSyncResponse { RequestID() int Status() GraphSyncStatus Extra() []bytes } interface GraphSyncMessage { Requests() : []GraphSyncRequest Responses() : []GraphSyncResponse Blocks() : []Blocks } interface Exportable { ToProto() ToNet(w io.Writer) error } Exportable --|> GraphSyncMessage GraphSyncRequest --* GraphSyncMessage GraphSyncResponse --* GraphSyncMessage } package ipldbridge { interface IPLDBridge { ValidateSelectorSpec(rootedSelector ipld.Node) []error EncodeNode(ipld.Node) ([]byte, error) DecodeNode([]byte) (ipld.Node, error) DecodeSelectorSpec(cidRootedSelector ipld.Node) (ipld.Node, Selector, error) Traverse(ctx context.Context, loader Loader, root ipld.Node, s Selector, fn AdvVisitFn) error } GraphSync *-- IPLDBridge RequestManager *-- IPLDBridge ResponseManager *-- IPLDBridge class ipldBridge { } object "PackagePublicFunctions" as goIPLDBridge { NewIPLDBridge() IPLDBridge } IPLDBridge <|-- ipldBridge goIPLDBridge .. ipldBridge ipldBridge *-- MulticodecDecodeTable ipldBridge *-- NodeBuilderChooser ipldBridge .. TraversalProgress ipldBridge .. goSelectorPF ipldBridge .. goIPLDReposePf } object "PackagePublicFunctions" as goGraphsyncPf { New(ctx context.Context, network GraphSyncNetwork, ipldBridge IPLDBridge, loader Loader) GraphSync LoaderFromCid2BlockFn(cid2BlockFn Cid2BlockFn) Loader SelectorSpecFromCidAndPath(lnk cid.Cid, pathSegments []string) (ipld.Node, error) } } package "go-filecoin" { class "go-filecoin" { } "go-filecoin" *-- GraphSync "go-filecoin" .. goGraphsyncPf "go-filecoin" .. goGraphSyncNetworkPF "go-filecoin" .. goIPLDBridge "go-filecoin" *-- RawLoader "go-filecoin" *-- MulticodecDecodeTable "go-filecoin" *-- NodeBuilderChooser } @enduml