Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(architecture): flesh out architecture docs
Provide a detailed guide to the architecture of go-graphsync Co-Authored-By: MollyM <momack2@users.noreply.github.com>
- Loading branch information
1 parent
8f2ae29
commit 480972a
Showing
10 changed files
with
591 additions
and
27 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
@startuml async loading | ||
participant IPLD | ||
participant "Intercepted Loader" as ILoader | ||
participant RequestManager | ||
participant AsyncLoader | ||
participant LoadAttemptQueue | ||
participant ResponseCache | ||
participant Loader | ||
participant Storer | ||
IPLD -> ILoader: Load Link | ||
activate ILoader | ||
ILoader -> AsyncLoader: Load Link Asynchronously | ||
activate AsyncLoader | ||
ILoader <-- AsyncLoader: Channel For future response | ||
... transfer to internal process ... | ||
AsyncLoader -> LoadAttemptQueue: Try Loading This Link | ||
deactivate AsyncLoader | ||
|
||
LoadAttemptQueue -> ResponseCache: Try Loading This Link | ||
alt response cache has block | ||
ResponseCache -> Storer: Store the block for later | ||
ResponseCache -> ResponseCache: Remove the block from cache | ||
LoadAttemptQueue <-- ResponseCache: "Here's the block" | ||
note over LoadAttemptQueue: Response = Block | ||
else response cache told block is missing by remote peer | ||
LoadAttemptQueue <-- ResponseCache: "We're missing this link" | ||
note over LoadAttemptQueue: Response = Error Missing Link | ||
else local store has block | ||
LoadAttemptQueue <-- ResponseCache: "I Don't Have it!" | ||
LoadAttemptQueue -> Loader: Try Loading This Link From Local Cache | ||
LoadAttemptQueue <-- Loader: "Here's the block" | ||
note over LoadAttemptQueue: Response = Block | ||
else no block or known missing link yet | ||
LoadAttemptQueue <-- ResponseCache: "I Don't Have it!" | ||
LoadAttemptQueue -> Loader: Try Loading This Link From Local Cache | ||
LoadAttemptQueue <-- Loader: "I Don't Have it!" | ||
LoadAttemptQueue -> LoadAttemptQueue: Store load request to try later | ||
end | ||
loop 0 or more times till I have a response for the link | ||
... | ||
opt new responses comes in | ||
RequestManager -> AsyncLoader: New Responses Present | ||
activate AsyncLoader | ||
AsyncLoader -> ResponseCache: New Responses Present | ||
... transfer to internal process ... | ||
AsyncLoader -> LoadAttemptQueue: Try Loading Again | ||
deactivate AsyncLoader | ||
LoadAttemptQueue -> ResponseCache: Try Loading Stored Links | ||
alt response cache now has block | ||
ResponseCache -> Storer: Store the block for later | ||
ResponseCache -> ResponseCache: Remove the block from cache | ||
LoadAttemptQueue <-- ResponseCache: "Here's the block" | ||
note over LoadAttemptQueue: Response = Block | ||
else response cache now knows link is missing by remote peer | ||
LoadAttemptQueue <-- ResponseCache: "We're missing this link" | ||
note over LoadAttemptQueue: Response = Error Missing Link | ||
else still no response | ||
LoadAttemptQueue <-- ResponseCache: "I don't have it" | ||
LoadAttemptQueue -> LoadAttemptQueue: Store load request to try later | ||
end | ||
end | ||
opt no more responses | ||
RequestManager -> AsyncLoader: No more responses | ||
activate AsyncLoader | ||
... transfer to internal process ... | ||
AsyncLoader -> LoadAttemptQueue: Cancel attempts to load | ||
note over LoadAttemptQueue: Response = Error Request Finished | ||
deactivate AsyncLoader | ||
end | ||
end | ||
ILoader <-- LoadAttemptQueue: Response Sent Over Channel | ||
IPLD <-- ILoader : "Here's the stream of block\n data or an error" | ||
deactivate ILoader | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
@startuml Overview | ||
start | ||
if () | ||
:Graphsync Client Makes Request; | ||
else | ||
:Incoming Network Traffic; | ||
:Message Decoding; | ||
endif | ||
partition "Top Level Interface" { | ||
:GraphSync; | ||
} | ||
if (operation type) then (outgoing request or incoming response) | ||
partition "Graphsync Requestor Implementation" { | ||
:RequestManager; | ||
if (operation type) then (incoming response) | ||
:AsyncLoader; | ||
partition "Verifying Queries" { | ||
fork | ||
:ipld.Traverse; | ||
fork again | ||
:ipld.Traverse; | ||
fork again | ||
:ipld.Traverse; | ||
end fork | ||
} | ||
partition "Collecting Responses" { | ||
fork | ||
:Response Collector; | ||
fork again | ||
:Response Collector; | ||
fork again | ||
:Response Collector; | ||
end fork | ||
} | ||
:Responses returned to client; | ||
stop | ||
else (outgoing request) | ||
:Send Request To Network; | ||
endif | ||
} | ||
else (incoming request) | ||
partition "Graphsync Responder Implementation" { | ||
:ResponseManager; | ||
partition "Performing Queries" { | ||
:PeerTaskQueue; | ||
fork | ||
:ipld.Traverse; | ||
fork again | ||
:ipld.Traverse; | ||
fork again | ||
:ipld.Traverse; | ||
end fork | ||
} | ||
partition "Aggregating Responses" { | ||
:PeerResponseManager; | ||
fork | ||
:PeerResponseSender; | ||
fork again | ||
:PeerResponseSender; | ||
fork again | ||
:PeerResponseSender; | ||
end fork | ||
} | ||
} | ||
endif | ||
partition "Message Sending Layer" { | ||
:PeerManager; | ||
fork | ||
:MessageQueue; | ||
fork again | ||
:MessageQueue; | ||
fork again | ||
:MessageQueue; | ||
end fork | ||
:Message Encoding; | ||
} | ||
:Outgoing Network Traffic; | ||
stop | ||
@enduml |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.