go-graphsync.puml 3.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
@startuml "GraphSync"

note top of "go-selector"
  Is this the right name for this package?
end note

package "go-selector" {

  interface Selector {
  }
  
  interface SelectionResponse {
  }
  
  interface SelectionTraverser {
    Next() SelectionResponse, err
    Cancel()
  }

  interface "GetBlockFunc func(cid) block.Block" as GetBlockFunc

  object "Package Public Functions" as goSelectorPF {
    Select(Selector, root Node, getBlockFunc GetBlockFunc) SelectionTraverser
    Validate(Selector, root Node, incomingResponses SelectionTraverser) SelectionTraverser
  }
}

package "go-graphsync" {
    class GraphSync {
      network : GraphySyncNetwork
      requestManager : RequestManager
      responseManager: ResponseManager
      getBlockFunc: GetBlockFunc

      Request(p peer.ID, selector Selector, root Node) SelectionTraverser
      ReceiveMessage(ctx context.Context, sender peer.ID, incoming GraphSyncMessage)
      ReceiveError(error)
    }
  

  package network {
    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)
    }

    Receiver <|-- GraphSync : receiver for

    class libP2PGraphSyncNetwork {

    }
    GraphSyncNetwork <|-- libP2PGraphSyncNetwork
    
    object "Package Public Functions" as goGraphSyncNetworkPF {
      NewLibP2PNetwork(host libp2pHost.Host) GraphSyncNetwork
    }
    goGraphSyncNetworkPF .. libP2PGraphSyncNetwork 
  }

  package requestmanager {
  class RequestManager {
    network : GraphSyncNetwork
    SendRequest(p peer.ID, selector Selector, node rootNode) SelectionTraverser
    ProcessResponses(responses []GraphSyncResponse)
  }
  goSelectorPF .. RequestManager
  RequestManager *-- GraphSyncNetwork
  GraphSync *-- RequestManager
  note as requestManager
    The ResponseManager uses Validate from go-selector
    to filter incoming Responses based on whether they are valid and produce
    a traverser that only returns valid responses
  end note
  }

  package responsemanager {
  class ResponseManager {
    network : GraphySyncNetwork
    getBlockFunc : GetBlockFunc
    ProcessRequests(p peer.ID, requests []GraphSyncRequests)
  }
  goSelectorPF .. ResponseManager
  ResponseManager *-- GraphSyncNetwork
  GraphSync *-- ResponseManager
  note as responseManagerNote
    The ResponseManager uses Select from go-selector
    to translate the raw bytes into a selector and then
    traverse the graph to produce a list of blocks

    Question: how to know if response is partial?
  end note
  }
  package message {
    object "Package Public Functions" as goGraphSyncMessagePF {
      func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error)
    }
    goGraphSyncMessagePF .. libP2PGraphSyncNetwork

    class GraphSyncRequest {
      Selector Selector
      Root     Node
      Priority Priority
      {field} Expires time.Duration
      Id       int
      IsCancel bool
    }

    class GraphSyncResponse {
      RequestId int
      Status GraphSyncStatus
    }

    interface GraphSyncMessage {
      Requests() : []GraphSyncRequest
      Responses() : []GraphSyncResponse
    }

    interface Exportable {
      ToProtoV0()
      ToProtoV1()
	  }

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

  object "PackagePublicFunctions" as goGraphsyncPf {
    New(ctx context.Context, network GraphSyncNetwork, getBlockFunc GetBlockFunc) GraphSync
  }

}

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

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

@enduml