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

3

4

5 6
package "go-ipld-prime" {
  interface Node {
7 8

  }
9
  interface Selector {
10 11 12 13 14
  }
  
}

package "go-graphsync" {
15
  
16 17 18 19
    class GraphSync {
      network : GraphySyncNetwork
      requestManager : RequestManager
      responseManager: ResponseManager
20
      Request(p peer.ID, selector Selector, root Cid) chan Block
21 22 23 24 25
      ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage)
      ReceiveError(error)
    }

  package network {
26
    
27 28 29 30 31 32 33 34
    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)
35
      ConnectTo(ctx context.Context, peer.ID) error
36 37 38 39 40 41 42
      NewMessageSender(context.Context, peer.ID) (MessageSender, error)
    }
    
    interface MessageSender {
	    SendMsg(context.Context, GraphSyncMessage) error
	    Close() error
	    Reset() error
43 44 45 46 47 48
    }

    Receiver <|-- GraphSync : receiver for

    class libP2PGraphSyncNetwork {
    }
49

50 51 52
    GraphSyncNetwork <|-- libP2PGraphSyncNetwork
    
    object "Package Public Functions" as goGraphSyncNetworkPF {
53
      NewLibP2PNetwork(host libp2pHost.Host) GraphSyncNetwork
54 55 56 57 58 59 60
    }
    goGraphSyncNetworkPF .. libP2PGraphSyncNetwork 
  }

  package requestmanager {
  class RequestManager {
    network : GraphSyncNetwork
61

62
    SendRequest(p peer.ID, selector Selector, root Cid) chan Block
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    ProcessResponses(responses []GraphSyncResponse)
  }
  RequestManager *-- GraphSyncNetwork
  GraphSync *-- RequestManager
  }

  package responsemanager {
  class ResponseManager {
    network : GraphySyncNetwork
    ProcessRequests(p peer.ID, requests []GraphSyncRequests)
  }
  ResponseManager *-- GraphSyncNetwork
  GraphSync *-- ResponseManager
  }
  package message {
    object "Package Public Functions" as goGraphSyncMessagePF {
79 80
      func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error)
      func FromNet(r io.Reader) (GraphSyncMessage, error)
81 82 83
    }
    goGraphSyncMessagePF .. libP2PGraphSyncNetwork

84
    interface GraphSyncRequest {
85
      Selector() []bytes
86 87 88
      Priority() Priority
      ID()       int
      IsCancel() bool
89 90
    }

91 92 93
    interface GraphSyncResponse {
      RequestID() int
      Status() GraphSyncStatus
94
      Extra() []bytes
95 96 97 98 99
    }

    interface GraphSyncMessage {
      Requests() : []GraphSyncRequest
      Responses() : []GraphSyncResponse
100
      Blocks() : []Blocks
101 102 103
    }

    interface Exportable {
104
      ToProto()
105
      ToNet(w io.Writer) error
106 107 108 109 110 111 112 113 114
	  }

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

  object "PackagePublicFunctions" as goGraphsyncPf {
115
    New(ctx context.Context, network GraphSyncNetwork) GraphSync
116 117 118 119 120 121 122 123 124 125 126 127 128 129
  }

}

package "go-filecoin" {
  class "go-filecoin" {
    graphSync : GraphSync
    host: libp2pHost.Host
  }

  "go-filecoin" *-- GraphSync
  "go-filecoin" .. goGraphsyncPf
  "go-filecoin" .. goGraphSyncNetworkPF
  "go-filecoin" .. Selector
130

131 132 133
}

@enduml