go-graphsync.puml 5.79 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

hannahhoward's avatar
hannahhoward committed
32 33 34
  interface Loader {

  }
35 36 37
}

package "go-graphsync" {
38
  
39 40 41 42 43
    class ResponseProgress {
      Node ipld.Node
      Path ipld.Path
      LastBlock struct {
        ipld.Node
hannahhoward's avatar
hannahhoward committed
44
        ipld.Link }
45 46 47 48 49
    }
    
    interface Cid2BlockFn {

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

57 58
    GraphSync *-- RawLoader

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

    Receiver <|-- GraphSync : receiver for

    class libP2PGraphSyncNetwork {
    }
83

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

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 122
  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
  }

123
  package requestmanager {
124 125 126 127
    interface ResponseProgress {

    }
    interface ResponseError {
128

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

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

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

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

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

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

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

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

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

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

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

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

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

231 232 233
}

@enduml