Skip to content

Commit

Permalink
Merge pull request #55 from ipfs/refactor/remove-bridge
Browse files Browse the repository at this point in the history
Tech Debt: Remove IPLD Bridge
  • Loading branch information
hannahhoward authored Mar 24, 2020
2 parents 1632890 + 8a792bb commit f22ce02
Show file tree
Hide file tree
Showing 54 changed files with 847 additions and 1,170 deletions.
57 changes: 16 additions & 41 deletions docs/go-graphsync.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ package "go-ipld-prime" {
package selector {
interface Selector {
}
object "PackagePublicFunctions" as goSelectorPF {
ReifySelector(cidRootedSelector Node) (Selector, error)
}
}
interface AdvVisitFn {
}
class TraversalConfig {
class Config {
}
class TraversalProgress {
TraverseInformatively(Node, Selector, AdvVisitFn)
class Progress {
WalkAdv(Node, Selector, AdvVisitFn)
}

TraversalProgress *-- TraversalConfig
Progress *-- Config
}

interface Storer {
Expand All @@ -40,7 +37,6 @@ package "go-ipld-prime" {
package "go-graphsync" {

interface Cid2BlockFn {

}
class GraphSync {
Request(ctx context.Context, p peer.ID, rootedSelector Node) (chan ResponseProgress, chan error)
Expand Down Expand Up @@ -219,7 +215,7 @@ package "go-graphsync" {
ProcessResponses(peer.ID, []GraphSyncResponse, []blocks.Block)
}
object "Package Public Functions" as goRequestManagerPF {
New(ctx context.Context, asyncLoader AsyncLoader, ipldBridge ipldbridge.IPLDBridge) *RequestManager
New(ctx context.Context, asyncLoader AsyncLoader) *RequestManager
}
RequestManager *-- AsyncLoader
RequestManager *-- PeerManager
Expand Down Expand Up @@ -301,7 +297,7 @@ package "go-graphsync" {
AddLink(GraphSyncRequestID, Link, bool)
AddCompletedRequest(GraphSyncRequestID, graphsync.ResponseStatusCode)
Empty() bool
Build(IPLDBridge) ([]GraphSyncResponse, []Block, error)
Build() ([]GraphSyncResponse, []Block, error)
}
object "Package Public Functions" as goResponseBuilderPF {
New() *ResponseBuilder
Expand All @@ -322,7 +318,7 @@ package "go-graphsync" {

object "Package Public Functions" as goPeerResponseManagerPF {
New(Context, func(Context, peer.ID) PeerResponseSender) *PeerResponseManager
NewResponseSender(Context, peer.ID, PeerMessageManager, IPLDBridge) PeerResponseSender
NewResponseSender(Context, peer.ID, PeerMessageManager) PeerResponseSender
}

PeerResponseManager *-- PeerResponseSender
Expand All @@ -339,7 +335,7 @@ package "go-graphsync" {
}

object "Package Public Functions" as goResponseManagerPF {
New(Context, Loader, IPLDBridge, PeerResponseManager, PeerTaskQueue) *ResponseManager
New(Context, Loader, PeerResponseManager, PeerTaskQueue) *ResponseManager
}
GraphSync *-- ResponseManager
ResponseManager *-- Loader
Expand Down Expand Up @@ -393,38 +389,18 @@ package "go-graphsync" {

}

package ipldbridge {
interface IPLDBridge {
EncodeNode(ipld.Node) ([]byte, error)
DecodeNode([]byte) (ipld.Node, error)
ParseSelector(selector ipld.Node) (Selector, error)
Traverse(ctx context.Context, loader Loader, root ipld.Node, s Selector, fn AdvVisitFn) error
}

GraphSync *-- IPLDBridge
RequestManager *-- IPLDBridge
ResponseManager *-- IPLDBridge
PeerResponseSender *-- IPLDBridge
package ipldutil {
object "Package Public Functions" as goIpldutilPF {

class ipldBridge {
EncodeNode(ipld.Node) ([]byte, error)
DecodeNode([]byte) (ipld.Node, error)
ParseSelector(selector ipld.Node) (Selector, error)
Traverse(ctx context.Context, loader Loader, root ipld.Node, s Selector, fn AdvVisitFn) error
}

object "PackagePublicFunctions" as goIPLDBridge {
NewIPLDBridge() IPLDBridge
}

IPLDBridge <|-- ipldBridge
goIPLDBridge .. ipldBridge
ipldBridge *-- MulticodecDecodeTable
ipldBridge *-- NodeBuilderChooser
ipldBridge .. TraversalProgress
ipldBridge .. goSelectorPF
ipldBridge .. goIPLDReposePf
}

object "PackagePublicFunctions" as goGraphsyncPf {
New(ctx context.Context, network GraphSyncNetwork, ipldBridge IPLDBridge, loader Loader) GraphSync
LoaderFromCid2BlockFn(cid2BlockFn Cid2BlockFn) Loader
SelectorSpecFromCidAndPath(lnk cid.Cid, pathSegments []string) (ipld.Node, error)
New(ctx context.Context, network GraphSyncNetwork, loader Loader, storer Storer) GraphSync
}
}

Expand All @@ -435,7 +411,6 @@ package "go-filecoin" {
"go-filecoin" *-- GraphSync
"go-filecoin" .. goGraphsyncPf
"go-filecoin" .. goGraphSyncNetworkPF
"go-filecoin" .. goIPLDBridge
"go-filecoin" *-- RawLoader
"go-filecoin" *-- MulticodecDecodeTable
"go-filecoin" *-- NodeBuilderChooser
Expand Down
Binary file modified docs/responder-sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions docs/responder-sequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ participant PeerResponseManager
participant PeerResponseSender
participant LinkTracker
participant ResponseBuilder
participant IPLDBridge
participant IPLD
participant "Intercepted Loader" as ILoader
participant Loader
participant "Message Sending\nLayer" as Message
Expand Down Expand Up @@ -44,23 +44,23 @@ QW -> PeerTaskQueue : Pop Request
PeerTaskQueue -> PeerTracker : Pop Request
PeerTracker -> PeerTaskQueue : Next Request\nTo Process
PeerTaskQueue -> QW : Next Request\nTo Process
QW -> IPLDBridge : DecodeNode
IPLDBridge -> QW : Selector Spec Node
QW -> IPLDBridge : ParseSelector
IPLDBridge -> QW : Root Node, IPLD Selector
QW -> IPLD : DecodeNode
IPLD -> QW : Selector Spec Node
QW -> IPLD : ParseSelector
IPLD -> QW : Root Node, IPLD Selector
QW -> PeerResponseManager : SenderForPeer
PeerResponseManager -> PeerResponseSender ** : Create for peer\nas neccesary
PeerResponseSender -> LinkTracker ** : Create
PeerResponseSender -> QW : PeerResponseSender
activate PeerResponseSender
QW -> ILoader ** : Create w/ RequestID, PeerResponseSender, Loader
QW -> IPLDBridge : Start Traversal Of Selector
QW -> IPLD : Start Traversal Of Selector
loop until traversal complete or request context cancelled
note over PeerResponseSender: Selector Traversal Loop
IPLDBridge -> ILoader : Request to load blocks\nto perform traversal
IPLD -> ILoader : Request to load blocks\nto perform traversal
ILoader -> Loader : Load blocks\nfrom local storage
Loader -> ILoader : Blocks From\nlocal storage or error
ILoader -> IPLDBridge : Blocks to continue\n traversal or error
ILoader -> IPLD : Blocks to continue\n traversal or error
ILoader -> PeerResponseSender : Block or error to Send Back
activate PeerResponseSender
PeerResponseSender -> LinkTracker : Notify block or\n error, ask whether\n block is duplicate
Expand All @@ -70,7 +70,7 @@ PeerResponseSender -> ResponseBuilder : Aggregate Response Metadata & Block
PeerResponseSender -> PeerResponseSender : Signal Work To Do
deactivate PeerResponseSender
end
IPLDBridge -> QW : Traversal Complete
IPLD -> QW : Traversal Complete
QW -> PeerResponseSender : Request Finished
activate PeerResponseSender
PeerResponseSender -> LinkTracker : Query If Errors\n Were Present
Expand Down
Binary file modified docs/top-level-sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions docs/top-level-sequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ participant Client
participant "GraphSync\nTop Level\nInterface" as TLI
participant "Requestor\nImplementation" as Requestor
participant "Responder\nImplementation" as Responder
participant IPLDBridge
participant IPLD
participant "Intercepted Loader" as ILoader
participant Loader
participant Storer
Expand All @@ -12,7 +12,7 @@ participant Network

== Initialization ==

Client -> TLI ** : Create With\nNetwork, Bridge,\nLoader/Storer
Client -> TLI ** : Create With\nNetwork\nLoader/Storer
TLI -> Requestor ** : Setup
TLI -> Responder ** : Setup
TLI -> Message ** : Setup
Expand All @@ -27,13 +27,13 @@ Message -> Network : Encode and Send\nRequest

Network -> TLI : Network receives message calls top level interface to process
TLI -> Responder : Send new request for processing
Responder -> IPLDBridge : Start a traversal\nof the selector
IPLDBridge -> ILoader : Request to load blocks\nto perform traversal
Responder -> IPLD : Start a traversal\nof the selector
IPLD -> ILoader : Request to load blocks\nto perform traversal
ILoader -> Loader : Load blocks\nfrom local storage
Loader -> ILoader : Blocks From\nlocal storage
par
ILoader -> IPLDBridge : Blocks to\ncontinue traversal
IPLDBridge -> Responder : Traversal completes to\nnotify response is done
ILoader -> IPLD : Blocks to\ncontinue traversal
IPLD -> Responder : Traversal completes to\nnotify response is done
else
ILoader -> Responder : Blocks+Responses To Send Back
end
Expand All @@ -44,15 +44,15 @@ Message -> Network : Encode and Send\nResponses+Blocks
Network -> TLI : Network receives message calls top level interface to process
TLI -> Requestor : Send Responses+Blocks\nfor Processing
par
Requestor -> IPLDBridge : Kick of selector traversal to verify response
IPLDBridge -> ILoader : Request to load blocks\nto perform traversal
Requestor -> IPLD : Kick of selector traversal to verify response
IPLD -> ILoader : Request to load blocks\nto perform traversal
else
Requestor -> ILoader : Blocks To Feed Back To Selector Verfication
end
ILoader -> Storer : Save blocks as they are verified
Storer -> ILoader : Blocks Were Stored
ILoader -> IPLDBridge : Blocks To Continue\n Ongoing Verification
IPLDBridge -> Requestor : New IPLD Nodes Visited
ILoader -> IPLD : Blocks To Continue\n Ongoing Verification
IPLD -> Requestor : New IPLD Nodes Visited
Requestor -> TLI : Stream Of\nNew IPLD Nodes
TLI -> Client: Stream Of\nNew IPLD Nodes
@enduml
36 changes: 14 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,30 @@ module github.com/ipfs/go-graphsync
go 1.12

require (
github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8 // indirect
github.com/gogo/protobuf v1.2.1
github.com/golang/protobuf v1.3.2 // indirect
github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce
github.com/gogo/protobuf v1.3.1
github.com/ipfs/go-bitswap v0.1.8
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.0
github.com/ipfs/go-cid v0.0.3
github.com/ipfs/go-datastore v0.0.5
github.com/ipfs/go-ipfs-blockstore v0.0.1
github.com/ipfs/go-blockservice v0.1.3-0.20190908200855-f22eea50656c
github.com/ipfs/go-cid v0.0.4-0.20191112011718-79e75dffeb10
github.com/ipfs/go-datastore v0.1.0
github.com/ipfs/go-ipfs-blockstore v0.1.0
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.1
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
github.com/ipfs/go-ipfs-files v0.0.4
github.com/ipfs/go-ipfs-util v0.0.1
github.com/ipfs/go-ipld-format v0.0.2
github.com/ipfs/go-log v0.0.1
github.com/ipfs/go-merkledag v0.2.3
github.com/ipfs/go-log v1.0.0
github.com/ipfs/go-merkledag v0.2.4
github.com/ipfs/go-peertaskqueue v0.2.0
github.com/ipfs/go-unixfs v0.2.2-0.20190827150610-868af2e9e5cb
github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785
github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/libp2p/go-eventbus v0.0.3 // indirect
github.com/libp2p/go-libp2p v0.2.1
github.com/libp2p/go-libp2p-core v0.0.9
github.com/libp2p/go-libp2p v0.3.0
github.com/libp2p/go-libp2p-core v0.2.4
github.com/libp2p/go-libp2p-peer v0.2.0
github.com/libp2p/go-libp2p-secio v0.1.1 // indirect
github.com/libp2p/go-msgio v0.0.4 // indirect
github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-dns v0.0.3 // indirect
github.com/multiformats/go-multihash v0.0.6
github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945 // indirect
go.opencensus.io v0.22.0 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e // indirect
github.com/multiformats/go-multiaddr v0.1.1
github.com/multiformats/go-multihash v0.0.9
)
Loading

0 comments on commit f22ce02

Please sign in to comment.