go-graphsync.puml 5.67 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
  package messagequeue {
    class MessageQueue {
94
      AddRequest(GraphSyncRequest)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
      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
112
      SendRequest(peer.ID, GraphSyncRequest)
113 114 115 116 117 118 119 120 121
    }

    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
    New(ctx context.Context, network GraphSyncNetwork, ipldBridge IPLDBridge, loader Loader) GraphSync
213 214
    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