go-graphsync.puml 5.54 KB
Newer Older
1 2
@startuml "GraphSync"

3

4

5 6
package "go-ipld-prime" {
  interface Node {
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  }
  interface NodeBuilder {
  }
  interface Path {
  }
  package traversal {
    package selector {
      interface Selector {
      }
      object "PackagePublicFunctions" as goSelectorPF {
        ReifySelector(cidRootedSelector Node) (Selector, error)
      }
    }
    interface AdvVisitFn {
    }
    class TraversalConfig {
      ctx context.Context
      linkLoader LinkLoader
    }
    class TraversalProgress {
      TraverseInformatively(Node, Selector, AdvVisitFn)
    }
29

30
    TraversalProgress *-- TraversalConfig
31
  }
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

  package repose {
    interface RawLoader {
    }

    interface MulticodecDecodeTable {
    }

    interface NodeBuilderChooser {
    }

    interface LinkLoader {
    }

    object "Package Public Functions" as goIPLDReposePf {
      ComposeLinkLoader(RawLoader, NodeBuilderChooser, MulticodecDecodeTable)
      EncoderDagCbor(Node, io.Writer)
      DecodeDagCbor(NodeBuilder, io.Writer)
    }  
51 52 53 54
  }
}

package "go-graphsync" {
55
  
56 57 58 59
    class GraphSync {
      network : GraphySyncNetwork
      requestManager : RequestManager
      responseManager: ResponseManager
60 61 62 63
      ipldBridge: IPLDBridge
      rawLoader: RawLoader
      
      Request(ctx context.Context, p peer.ID, cidRootedSelector Node) chan Block
64 65 66 67
      ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage)
      ReceiveError(error)
    }

68 69
    GraphSync *-- RawLoader

70
  package network {
71
    
72 73 74 75 76 77 78 79
    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)
80
      ConnectTo(ctx context.Context, peer.ID) error
81 82 83 84 85 86 87
      NewMessageSender(context.Context, peer.ID) (MessageSender, error)
    }
    
    interface MessageSender {
	    SendMsg(context.Context, GraphSyncMessage) error
	    Close() error
	    Reset() error
88 89 90 91 92 93
    }

    Receiver <|-- GraphSync : receiver for

    class libP2PGraphSyncNetwork {
    }
94

95 96 97
    GraphSyncNetwork <|-- libP2PGraphSyncNetwork
    
    object "Package Public Functions" as goGraphSyncNetworkPF {
98
      NewLibP2PNetwork(host libp2pHost.Host) GraphSyncNetwork
99 100 101 102 103 104 105
    }
    goGraphSyncNetworkPF .. libP2PGraphSyncNetwork 
  }

  package requestmanager {
  class RequestManager {
    network : GraphSyncNetwork
106
    ipldBridge: GraphSyncNetwork
107

108
    SendRequest(ctx context.Context, p peer.ID, cidRootedSelector Node) chan Block
109 110 111 112 113 114 115 116 117
    ProcessResponses(responses []GraphSyncResponse)
  }
  RequestManager *-- GraphSyncNetwork
  GraphSync *-- RequestManager
  }

  package responsemanager {
  class ResponseManager {
    network : GraphySyncNetwork
118 119 120
    ipldBridge: IPLDBridge
    rawLoader: RawLoader

121 122 123 124
    ProcessRequests(p peer.ID, requests []GraphSyncRequests)
  }
  ResponseManager *-- GraphSyncNetwork
  GraphSync *-- ResponseManager
125
  ResponseManager *-- RawLoader
126 127 128
  }
  package message {
    object "Package Public Functions" as goGraphSyncMessagePF {
129 130
      func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error)
      func FromNet(r io.Reader) (GraphSyncMessage, error)
131 132 133
    }
    goGraphSyncMessagePF .. libP2PGraphSyncNetwork

134
    interface GraphSyncRequest {
135
      Selector() []bytes
136 137 138
      Priority() Priority
      ID()       int
      IsCancel() bool
139 140
    }

141 142 143
    interface GraphSyncResponse {
      RequestID() int
      Status() GraphSyncStatus
144
      Extra() []bytes
145 146 147 148 149
    }

    interface GraphSyncMessage {
      Requests() : []GraphSyncRequest
      Responses() : []GraphSyncResponse
150
      Blocks() : []Blocks
151 152 153
    }

    interface Exportable {
154
      ToProto()
155
      ToNet(w io.Writer) error
156 157 158 159 160 161 162 163
	  }

    Exportable --|> GraphSyncMessage
    GraphSyncRequest --* GraphSyncMessage
    GraphSyncResponse --* GraphSyncMessage
    
  }

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
  package ipldbridge {
    interface IPLDBridge {
      ComposeLinkLoader(actualLoader RawLoader) LinkLoader
	    ValidateSelectorSpec(cidRootedSelector 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 LinkLoader, root ipld.Node, s Selector, fn AdvVisitFn) error
    }

    GraphSync *-- IPLDBridge
    RequestManager *-- IPLDBridge
    ResponseManager *-- IPLDBridge
  
    class ipldBridge {
      nodeBuilderChooser: NodeBuilderChooser
      multicodecTable: MulticodecDecodeTable
    }

    object "PackagePublicFunctions" as goIPLDBridge {
      NewIPLDBridge(nodeBuilderChooser NodeBuilderChooser, multicodecTable MulticodecDecodeTable) IPLDBridge
    }

    IPLDBridge <|-- ipldBridge
    goIPLDBridge .. ipldBridge 
    ipldBridge *-- MulticodecDecodeTable
    ipldBridge *-- NodeBuilderChooser
    ipldBridge .. TraversalProgress
    ipldBridge .. goSelectorPF
    ipldBridge .. goIPLDReposePf
  }
195
  object "PackagePublicFunctions" as goGraphsyncPf {
196
    New(ctx context.Context, network GraphSyncNetwork, rawLoader RawLoader, multicodecDecodeTable MulticodecDecodeTable, nodeBuilderChooser NodeBuilderChooser) GraphSync
197 198 199 200 201 202 203 204
  }

}

package "go-filecoin" {
  class "go-filecoin" {
    graphSync : GraphSync
    host: libp2pHost.Host
205 206 207
    nodeBuilderChooser: NodeBuilderChooser
    multicodecTable: MulticodecDecodeTable
    rawLoader: RawLoader
208 209 210 211 212
  }

  "go-filecoin" *-- GraphSync
  "go-filecoin" .. goGraphsyncPf
  "go-filecoin" .. goGraphSyncNetworkPF
213 214 215 216
  "go-filecoin" .. goIPLDBridge
  "go-filecoin" *-- RawLoader
  "go-filecoin" *-- MulticodecDecodeTable
  "go-filecoin" *-- NodeBuilderChooser
217

218 219 220
}

@enduml