go-graphsync.puml 5.93 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
  }
  interface NodeBuilder {
  }
  interface Path {
  }
  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)
    }
27

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

  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)
    }  
49 50 51 52
  }
}

package "go-graphsync" {
53
  
54
    class GraphSync {
55
      Request(ctx context.Context, p peer.ID, cidRootedSelector Node) (chan ResponseProgress, chan ResponseError)
56 57 58 59
      ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage)
      ReceiveError(error)
    }

60 61
    GraphSync *-- RawLoader

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

    Receiver <|-- GraphSync : receiver for

    class libP2PGraphSyncNetwork {
    }
86

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

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 123 124 125
  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
  }

126
  package requestmanager {
127 128 129 130
    interface ResponseProgress {

    }
    interface ResponseError {
131

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

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

157
    interface GraphSyncRequest {
158
      Selector() []bytes
159 160 161
      Priority() Priority
      ID()       int
      IsCancel() bool
162 163
    }

164 165 166
    interface GraphSyncResponse {
      RequestID() int
      Status() GraphSyncStatus
167
      Extra() []bytes
168 169 170 171 172
    }

    interface GraphSyncMessage {
      Requests() : []GraphSyncRequest
      Responses() : []GraphSyncResponse
173
      Blocks() : []Blocks
174 175 176
    }

    interface Exportable {
177
      ToProto()
178
      ToNet(w io.Writer) error
179 180 181 182 183 184 185 186
	  }

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

187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
  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 {
    }

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

    IPLDBridge <|-- ipldBridge
    goIPLDBridge .. ipldBridge 
    ipldBridge *-- MulticodecDecodeTable
    ipldBridge *-- NodeBuilderChooser
    ipldBridge .. TraversalProgress
    ipldBridge .. goSelectorPF
    ipldBridge .. goIPLDReposePf
  }
216
  object "PackagePublicFunctions" as goGraphsyncPf {
217
    New(ctx context.Context, network GraphSyncNetwork, rawLoader RawLoader, multicodecDecodeTable MulticodecDecodeTable, nodeBuilderChooser NodeBuilderChooser) GraphSync
218 219 220 221 222 223 224 225 226 227
  }
}

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

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

233 234 235
}

@enduml