-
-
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
Added experimental index provider feature to go-ipfs #8771
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,7 @@ docs/examples/go-ipfs-as-a-library/example-folder/Qm* | |
/parts | ||
/stage | ||
/prime | ||
|
||
# ignore vscode config | ||
.vscode | ||
.idea |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,9 @@ const ( | |
enableIPNSPubSubKwd = "enable-namesys-pubsub" | ||
enableMultiplexKwd = "enable-mplex-experiment" | ||
agentVersionSuffix = "agent-version-suffix" | ||
enableIndexerProviderKwd = "index-provider-experiment" | ||
indexerProviderFullKwd = "index-provider-full-import-experiment" | ||
|
||
// apiAddrKwd = "address-api" | ||
// swarmAddrKwd = "address-swarm" | ||
) | ||
|
@@ -181,6 +184,8 @@ Headers. | |
cmds.BoolOption(enablePubSubKwd, "Enable experimental pubsub feature. Overrides Pubsub.Enabled config."), | ||
cmds.BoolOption(enableIPNSPubSubKwd, "Enable IPNS over pubsub. Implicitly enables pubsub, overrides Ipns.UsePubsub config."), | ||
cmds.BoolOption(enableMultiplexKwd, "DEPRECATED"), | ||
cmds.StringOption(enableIndexerProviderKwd, "Enable experimental indexer provider feature and provide new Cids that are added, with indexer address"), | ||
cmds.StringOption(indexerProviderFullKwd, "Enable experimental indexer provider feature and provide all locally stored Cids, with indexer address"), | ||
cmds.StringOption(agentVersionSuffix, "Optional suffix to the AgentVersion presented by `ipfs id` and also advertised through BitSwap."), | ||
|
||
// TODO: add way to override addresses. tricky part: updating the config if also --init. | ||
|
@@ -541,6 +546,37 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment | |
fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)") | ||
}() | ||
|
||
idxProviderAddress, idxProviderSet := req.Options[enableIndexerProviderKwd].(string) | ||
idxProviderFullAddress, idxProviderFullSet := req.Options[indexerProviderFullKwd].(string) | ||
|
||
// if idxProviderFull is set, we will provide all existing blocks we have. This | ||
// is meant to be a one-time operation, and not meant to be used at the same time | ||
// as the idxProviderSet - which advertises newly added blocks on a timer | ||
idxProviderNode := &ipfsIdxProviderNode{node} | ||
if idxProviderFullSet { | ||
Comment on lines
+552
to
+556
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New components, whether configurable or not, being instantiated in Instead this logic should live in Happy to give more guidance here if needed. |
||
err := setupIdxProvider(cctx, idxProviderNode, idxProviderFullAddress) | ||
if err != nil { | ||
log.Errorf("error setting up idx provider: %s", err) | ||
return err | ||
} | ||
err = advertiseAllCids(cctx.Context(), idxProviderNode) | ||
if err != nil { | ||
log.Errorf("error advertising local cids: %s", err) | ||
return err | ||
} | ||
} | ||
if idxProviderSet { | ||
err = setupIdxProvider(cctx, &ipfsIdxProviderNode{node}, idxProviderAddress) | ||
if err != nil { | ||
log.Errorf("error setting up idx provider: %s", err) | ||
return err | ||
} | ||
// wrap the blockstore in a providerBlockstore so we can watch for puts/deletes | ||
pbs := NewProviderBlockstore(node.BaseBlocks) | ||
pbs.startBlockstoreProvider(cctx, idxProviderNode) | ||
node.BaseBlocks = pbs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing this is generally unsafe and likely won't help you out with anything since at this point any other parts of the program that already have access to this pointer have already moved on and won't notice this change. This should be done within the dependency injection/node creation. 🐉 🐉 🐉 It's because However, other functionality such as which leverages an existing dagservice (there's a blockstore underneath all that) Offhand, I'm not sure if |
||
} | ||
|
||
// Give the user heads up if daemon running in online mode has no peers after 1 minute | ||
if !offline { | ||
time.AfterFunc(1*time.Minute, func() { | ||
|
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.
Going to use this area to talk about some potential design issues because I think a thread will be useful here and GitHub doesn't provide them unless you anchor to some code.
My understanding of the design here is that you're planning to run this fork by:
ipfs daemon --index-provider-full-import-experiment
once, waiting for everything to finish by watching some logsipfs daemon --index-provider-experiment
which will periodically notice any new blocks you have added locally and advertise themSome things that this misses, some of which you might be ok with and some not. (Note: most if not all of these are likely blockers to merging the code upstream, but we can go a step at a time here)
ipfs add
while the daemon isn't running) the advertisement will get dropped. Potentially fixable, but at the cost of adding tiny advertisements which IIUC perform poorly with indexer syncingIIUC a pattern which might be more useful for your use case (a pinning service with lots of data it wants to advertise to the indexers) might look like this:
Some advantages:
Some disadvantages:
The above are just some suggestions though, some of the error cases unhandled by this design that can show up might not be a problem at the moment to start with.