@startuml "GraphSync" package "go-ipld-format" { interface Node } note top of "go-selector" Is this the right name for this package? end note package "go-selector" { interface Selector { } interface SelectionResponse { } interface SelectionTraverser { Next() SelectionResponse, err Cancel() } interface "GetBlockFunc func(cid) block.Block" as GetBlockFunc interface SelectorQuerier { Select(Selector, root Node) SelectionTraverser Validate(Selector, root Node, incomingResponses SelectionTraverser) SelectionTraverser } object "Package Public Functions" as goSelectorPF { NewSelectorQuerier(getBlockFunc GetBlockFunc) SelectorQuerier } Node <|-- Selector Node <|-- SelectionResponse } package "go-graphsync" { class GraphSync { network : GraphySyncNetwork requestManager : RequestManager responseManager: ResponseManager selectorQuerier: SelectorQuerier Request(p peer.ID, selector Selector, root Node) SelectionTraverser ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage) ReceiveError(error) } GraphSync *-- SelectorQuerier 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) } Receiver <|-- GraphSync : receiver for class libP2PGraphSyncNetwork { } GraphSyncNetwork <|-- libP2PGraphSyncNetwork object "Package Public Functions" as goGraphSyncNetworkPF { NewLibP2PNetwork(host libp2pHost.Host, decodeSelectionResponseFunc: DecodeSelectionResponseFunc, decodeSelectorFunc: DecodeSelectorFunc, decodeRootNodeFunc: DecodeRootNodeFunc) GraphSyncNetwork } goGraphSyncNetworkPF .. libP2PGraphSyncNetwork } package requestmanager { class RequestManager { network : GraphSyncNetwork selectorQuerier: SelectorQuerier SendRequest(p peer.ID, selector Selector, node rootNode) SelectionTraverser ProcessResponses(responses []GraphSyncResponse) } SelectorQuerier --* RequestManager RequestManager *-- GraphSyncNetwork GraphSync *-- RequestManager note as requestManager The ResponseManager uses Validate from go-selector to filter incoming Responses based on whether they are valid and produce a traverser that only returns valid responses end note } package responsemanager { class ResponseManager { network : GraphySyncNetwork selectorQuerier: SelectorQuerier ProcessRequests(p peer.ID, requests []GraphSyncRequests) } SelectorQuerier --* ResponseManager ResponseManager *-- GraphSyncNetwork GraphSync *-- ResponseManager note as responseManagerNote The ResponseManager uses Select from go-selector to translate the raw bytes into a selector and then traverse the graph to produce a list of blocks Question: how to know if response is partial? end note } package message { interface "DecodeSelectionResponseFunc func([]byte) SelectionResponse" as DecodeSelectionResponseFunc interface "DecodeSelectorFunc func([]byte) Selector" as DecodeSelectorFunc interface "DecodeRootNodeFunc func([]byte) Node" as DecodeRootNodeFunc object "Package Public Functions" as goGraphSyncMessagePF { func FromPBReader(pbr ggio.Reader, decodeSelectionResponseFunc: DecodeSelectionResponseFunc, decodeSelectorFunc: DecodeSelectorFunc, decodeRootNodeFunc: DecodeRootNodeFunc) (GraphSyncMessage, error) } goGraphSyncMessagePF .. libP2PGraphSyncNetwork interface GraphSyncRequest { Selector() Selector Root() Node Priority() Priority ID() int IsCancel() bool } interface GraphSyncResponse { RequestID() int Status() GraphSyncStatus } interface GraphSyncMessage { Requests() : []GraphSyncRequest Responses() : []GraphSyncResponse } interface Exportable { ToProto() } Exportable --|> GraphSyncMessage GraphSyncRequest --* GraphSyncMessage GraphSyncResponse --* GraphSyncMessage } object "PackagePublicFunctions" as goGraphsyncPf { New(ctx context.Context, network GraphSyncNetwork, getBlockFunc GetBlockFunc) GraphSync } } package "go-filecoin" { class "go-filecoin" { graphSync : GraphSync selectorQuerier: SelectorQuerier host: libp2pHost.Host decodeSelectionResponseFunc: DecodeSelectionResponseFunc decodeSelectorFunc: DecodeSelectorFunc decodeRootNodeFunc: DecodeRootNodeFunc } "go-filecoin" *-- GraphSync "go-filecoin" .. goGraphsyncPf "go-filecoin" .. goGraphSyncNetworkPF "go-filecoin" .. Selector "go-filecoin" *-- SelectorQuerier "go-filecoin" .. goSelectorPF } @enduml