-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoreAPI: Global offline option #5825
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in general LGTM (but I can't really comment on the design decision of extracting all of the IpfsNode
attributes here).
core/coreapi/coreapi.go
Outdated
|
||
// TODO: this can be generalized to all functions when we implement some | ||
// api based security mechanism | ||
isPublishAllowed func() error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't really about security. Really, we should allow publishing IPNS records while /ipns is mounted. We don't currently because we haven't implemented that yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I just wanted to hint that something like this may be useful (but a full security layer implementing coreapi interface would probably be better)
core/commands/cmdenv/env.go
Outdated
ctx, ok := env.(*commands.Context) | ||
if !ok { | ||
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) | ||
} | ||
|
||
return ctx.GetAPI() | ||
local, _ := req.Options["local"].(bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this'll apply this option (correctly) to all commands fixing part of #4182. I wonder if we should fix the "confusing" part while we're at it by renaming this option to "offline" (keeping a hidden alias for compatibility).
That would also allow us to share the same option with ipfs daemon --offline
which should help to further reduce confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with doing that (the hidden alias could throw warnings at people). This will probably need support on the js side too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize js replicated that option.
@alanshaw how would you feel about switching from --local
to --offline
(keeping --local
as a backcompat alias)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented, waiting for @alanshaw's opinion (assuming js-ipfs implements --local
)
a16a5ba
to
7ddb45f
Compare
4eccfa9
to
6de9b03
Compare
core/coreapi/coreapi.go
Outdated
|
||
cs := cfg.Ipns.ResolveCacheSize | ||
if cs == 0 { | ||
cs = 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should lift this to a constant.
} | ||
|
||
bserv := blockservice.New(addblockstore, exch) // hash security 001 | ||
dserv := dag.NewDAGService(bserv) | ||
|
||
fileAdder, err := coreunix.NewAdder(ctx, n.Pinning, n.Blockstore, dserv) | ||
fileAdder, err := coreunix.NewAdder(ctx, pinning, addblockstore, dserv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bugfix or a bug? It's now using addblocksore
where it used to use the unmodified blockstore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bugfix - coreunix.NewAdder
uses it only for the GCLock
, which we don't want/need to take from the 'real' node when we do add with OnlyHash
set.
Mostly nits at this point but you should take a look at #5825 (comment). |
@ipfs/go-team this is an interface change (but not a breaking one). It replaces Suggestions? Objections? |
00dddb3
to
81fa251
Compare
(rebased) |
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
81fa251
to
6044d2a
Compare
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
CoreAPI: Global offline option This commit was moved from ipfs/kubo@28dabc7
For #5654. This implements the 'Functional options on the constructor' approach.
I decided to not use
core.IpfsNode
directly in coreapi as this way we have much better control over how the internals are used. Longer term, after coreapi interface is extracted form go-ipfs, I plan on merging a lot of core node and coreapi functionality, but I want to do that together with go-ipfs constructor cleanup as it will be quite breaking for people usingcore.IpfsNode
directly (there still are good reasons to do that)A few bugs and todos are still left, reviews welcome