Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e6b7dea

Browse files
committedJun 3, 2015
Revert "Replace single callbacks with slices of function references"
This reverts commit d617dfb. On Wed, Jun 03, 2015 at 01:54:03AM -0700, Juan Batiz-Benet wrote [1]: > > it's probably worth passing an array of NodeCallback (and > > PreNodeCallback) references to the adders > > i think this is way overkill. one can chain the calls with one > function themselves. you might even provide a utility function that > turns N callbacks into one which applies them sequentially, but this > function should just accept one callback. That's a much cleaner approach, so we're going back to the non-slice callbacks. [1]: #1291 (comment)
1 parent d617dfb commit e6b7dea

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed
 

‎add-api.md

+14-23
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,12 @@ I'd suggest moving `core/coreunix` to `core/unixfs` to match
7474
// node: And IPFS node for storing newly-created DAG nodes.
7575
// file: An open file pointing at the root of the filesystem to be
7676
// added.
77-
// preNodeCallBacks: An optional slice of hooks for pre-DAG-node
78-
// checks (e.g. ignoring boring paths). Before adding a path,
79-
// Add will iterate through the preNodeCallbacks and ignore
80-
// the path (and stop further preNodeCallbacks iteration) if
81-
// any of the callbacks set ignore to true. Set to nil if you
82-
// don't need it.
83-
// postNodeCallBacks: An optional slice of hooks for
84-
// post-DAG-node processing (e.g. altering or wrapping the
85-
// newly-created nodes). After creating a node, Add will
86-
// iterate through the postNodeCallbacks, passing nodeOut from
87-
// earlier callbacks in as nodeIn to the next callback. For
88-
// example, if Add internally creates node1, the first
89-
// callback will get node1 as nodeIn. If that callback
90-
// returns node2 (possibly nil), the second callback will get
91-
// node2 as nodeIn. Set to nil if you don't need it.
77+
// preNodeCallBack: An optional hook for pre-DAG-node checks
78+
// (e.g. ignoring boring paths). Set to nil if you don't need
79+
// it.
80+
// postNodeCallBack: An optional hook for post-DAG-node
81+
// processing (e.g. altering or wrapping the newly-created
82+
// nodes). Set to nil if you don't need it.
9283
//
9384
// The returned values are:
9485
//
@@ -98,8 +89,8 @@ I'd suggest moving `core/coreunix` to `core/unixfs` to match
9889
ctx context.Context,
9990
node *core.IpfsNode,
10091
file *os.File,
101-
preNodeCallBacks []*PreNodeCallback,
102-
postNodeCallbacks []*PostNodeCallback
92+
preNodeCallBack *PreNodeCallback,
93+
postNodeCallback *PostNodeCallback
10394
) (root *dag.Node, err error)
10495

10596
// AddFromReader adds a file from an io.Reader. It is otherwise
@@ -108,8 +99,8 @@ I'd suggest moving `core/coreunix` to `core/unixfs` to match
10899
ctx context.Context,
109100
node *core.IpfsNode,
110101
reader io.Reader,
111-
preNodeCallBacks []*PreNodeCallback,
112-
postNodeCallbacks []*PostNodeCallback
102+
preNodeCallBack *PreNodeCallback,
103+
postNodeCallback *PostNodeCallback
113104
) (root *dag.Node, err error)
114105

115106
Most additions will be recursive and load data from a [*File][File]
@@ -144,17 +135,17 @@ layout, and splitter, we pass each of those in explicitly:
144135
layout _layout.Layout,
145136
splitter chunk.BlockSplitter,
146137
file *os.File,
147-
preNodeCallBacks []*PreNodeCallback,
148-
postNodeCallbacks []*PostNodeCallback
138+
preNodeCallBack *PreNodeCallback,
139+
postNodeCallback *PostNodeCallback
149140
) (root *dag.Node, err error)
150141
AddFromReader(
151142
ctx context.Context,
152143
dagService dag.DAGService,
153144
layout _layout.Layout,
154145
splitter chunk.BlockSplitter,
155146
reader io.Reader,
156-
preNodeCallBacks []*PreNodeCallback,
157-
postNodeCallbacks []*PostNodeCallback
147+
preNodeCallBack *PreNodeCallback,
148+
postNodeCallback *PostNodeCallback
158149
) (root *dag.Node, error)
159150

160151
We don't currently have a public `Layout` interface, but I think we

0 commit comments

Comments
 (0)
Please sign in to comment.