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

3

4

5 6
package "go-ipld-prime" {
  interface Node {
7 8 9 10 11
  }
  interface NodeBuilder {
  }
  interface Path {
  }
12
  interface Link
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  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)
    }
28

29
    TraversalProgress *-- TraversalConfig
30
  }
31

32
  interface Loader {}
33 34 35
}

package "go-graphsync" {
36
  
37 38 39 40 41 42 43 44 45 46 47 48
    class ResponseProgress {
      Node ipld.Node
      Path ipld.Path
      LastBlock struct {
        ipld.Node
        ipld.Link
      }
    }
    
    interface Cid2BlockFn {

    }
49
    class GraphSync {
50 51 52
      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)     
53 54 55
      ReceiveError(error)
    }

56 57
    GraphSync *-- RawLoader

58
  package network {
59
    
60 61 62 63 64 65 66 67
    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)
68
      ConnectTo(ctx context.Context, peer.ID) error
69 70 71 72 73 74 75
      NewMessageSender(context.Context, peer.ID) (MessageSender, error)
    }
    
    interface MessageSender {
	    SendMsg(context.Context, GraphSyncMessage) error
	    Close() error
	    Reset() error
76 77 78 79 80 81
    }

    Receiver <|-- GraphSync : receiver for

    class libP2PGraphSyncNetwork {
    }
82

83 84 85
    GraphSyncNetwork <|-- libP2PGraphSyncNetwork
    
    object "Package Public Functions" as goGraphSyncNetworkPF {
86
      NewLibP2PNetwork(host libp2pHost.Host) GraphSyncNetwork
87 88 89 90
    }
    goGraphSyncNetworkPF .. libP2PGraphSyncNetwork 
  }

91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
  package messagequeue {
    class MessageQueue {
      AddRequest(GraphSyncRequestID, selector []byte, GraphSyncPriority)
      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, GraphSyncRequestID, selector []byte, priority)
      CancelRequest(peer.ID, GraphSyncRequestID)
    }

    object "Package Public Functions" as goPeerManagerPF {
      New(ctx context.Context, createPeerQueue func(context, peer.ID) MessageQueue)
    }
    GraphSync .. goPeerManagerPF
    PeerManager *-- MessageQueue
  }

122
  package requestmanager {
123 124 125 126
    interface ResponseProgress {

    }
    interface ResponseError {
127

128 129 130
    }
  class RequestManager {
    SetDelegate(peerHandler PeerManager)
131
    SendRequest(ctx context.Context, p peer.ID, cidRootedSelector Node) chan Block
132
    ProcessResponses(message GraphSyncMessage)
133
  }
134
  RequestManager *-- PeerManager
135 136 137 138 139 140 141 142 143
  GraphSync *-- RequestManager
  }

  package responsemanager {
  class ResponseManager {
    ProcessRequests(p peer.ID, requests []GraphSyncRequests)
  }
  ResponseManager *-- GraphSyncNetwork
  GraphSync *-- ResponseManager
144
  ResponseManager *-- RawLoader
145 146 147
  }
  package message {
    object "Package Public Functions" as goGraphSyncMessagePF {
148 149
      func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error)
      func FromNet(r io.Reader) (GraphSyncMessage, error)
150 151 152
    }
    goGraphSyncMessagePF .. libP2PGraphSyncNetwork

153
    interface GraphSyncRequest {
154
      Selector() []bytes
155 156 157
      Priority() Priority
      ID()       int
      IsCancel() bool
158 159
    }

160 161 162
    interface GraphSyncResponse {
      RequestID() int
      Status() GraphSyncStatus
163
      Extra() []bytes
164 165 166 167 168
    }

    interface GraphSyncMessage {
      Requests() : []GraphSyncRequest
      Responses() : []GraphSyncResponse
169
      Blocks() : []Blocks
170 171 172
    }

    interface Exportable {
173
      ToProto()
174
      ToNet(w io.Writer) error
175 176 177 178 179 180 181 182
	  }

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

183 184
  package ipldbridge {
    interface IPLDBridge {
185
	    ValidateSelectorSpec(rootedSelector ipld.Node) []error
186 187 188
	    EncodeNode(ipld.Node) ([]byte, error)
	    DecodeNode([]byte) (ipld.Node, error)
	    DecodeSelectorSpec(cidRootedSelector ipld.Node) (ipld.Node, Selector, error)
189
	    Traverse(ctx context.Context, loader Loader, root ipld.Node, s Selector, fn AdvVisitFn) error
190 191 192 193 194 195 196 197 198 199
    }

    GraphSync *-- IPLDBridge
    RequestManager *-- IPLDBridge
    ResponseManager *-- IPLDBridge
  
    class ipldBridge {
    }

    object "PackagePublicFunctions" as goIPLDBridge {
200
      NewIPLDBridge() IPLDBridge
201 202 203 204 205 206 207 208 209 210
    }

    IPLDBridge <|-- ipldBridge
    goIPLDBridge .. ipldBridge 
    ipldBridge *-- MulticodecDecodeTable
    ipldBridge *-- NodeBuilderChooser
    ipldBridge .. TraversalProgress
    ipldBridge .. goSelectorPF
    ipldBridge .. goIPLDReposePf
  }
211
  object "PackagePublicFunctions" as goGraphsyncPf {
212 213 214
    New(ctx context.Context, network GraphSyncNetwork, loader Loader) GraphSync
    LoaderFromCid2BlockFn(cid2BlockFn Cid2BlockFn) Loader
    SelectorSpecFromCidAndPath(lnk cid.Cid, pathSegments []string) (ipld.Node, error) 
215 216 217 218 219 220 221 222 223 224
  }
}

package "go-filecoin" {
  class "go-filecoin" {
  }

  "go-filecoin" *-- GraphSync
  "go-filecoin" .. goGraphsyncPf
  "go-filecoin" .. goGraphSyncNetworkPF
225 226 227 228
  "go-filecoin" .. goIPLDBridge
  "go-filecoin" *-- RawLoader
  "go-filecoin" *-- MulticodecDecodeTable
  "go-filecoin" *-- NodeBuilderChooser
229

230 231 232
}

@enduml