Skip to content
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

Kubo as a Library Example; Seemingly not workable outside of the parent Kubo repo #9828

Closed
2 tasks done
AustinFoss opened this issue Apr 19, 2023 · 4 comments
Closed
2 tasks done
Labels
kind/stale need/author-input Needs input from the original author P2 Medium: Good to have, but can wait until someone steps up

Comments

@AustinFoss
Copy link

Checklist

Location

https://github.com/ipfs/kubo/blob/master/docs/examples/kubo-as-a-library/main.go#L133

Description

I've been trying to explore using p2phttp and wanted to try providing a Kubo node as the host.Host argument for the gostream.Listen() function: https://github.com/libp2p/go-libp2p-http

While attempting to do so and exploring the Kubo as a Library example I came up bad behavior from the example where a return value, api, from the spawnEphemerral() function is conflicting with the expected return type: https://github.com/ipfs/kubo/blob/master/docs/examples/kubo-as-a-library/main.go#L111

The problem appears as soon as this example is seperated from the parent repo, but works just fine as long as it's nested as a child within the examples folder of this repo. The variable type in question causing the conflict reads:

cannot use api (variable of type “GitHub - ipfs/interface-go-ipfs-core”.CoreAPI) as “github.com/ipfs/boxo/coreiface”.CoreAPI value in return statement: “GitHub - ipfs/interface-go-ipfs-core”.CoreAPI does not implement “github.com/ipfs/boxo/coreiface”.CoreAPI (wrong type for method Block)

Seems there's something going on with the versioning around ipfs/boxo but that's as far as I'm gonna go because the version your example uses seems to be an early release, 0.8.1-0.20230411232920-5d6c73c8e35e, so I'll probably stop here and wait until that release is finalized and maybe resolves this problem.

I noticed as well that while the comments in the go.mod file mentioned to comment out the "replace github.com/ipfs/kubo => ./../../.." line, but still says to use GoV1.18 when the current version of QUIC requires at least 1.19.

@AustinFoss AustinFoss added need/triage Needs initial labeling and prioritization topic/docs-ipfs Topic docs-ipfs labels Apr 19, 2023
@AustinFoss
Copy link
Author

AustinFoss commented Apr 19, 2023

It's really odd (okay, I didn't just stop there and kept digging), when I compared the two interfaces:

Boxo: https://github.com/ipfs/boxo/blob/main/coreiface/coreapi.go
go-ipfs: https://github.com/ipfs/interface-go-ipfs-core/blob/master/coreapi.go

They're identical near as I can tell so it's only throwing the error because the two interfaces, despite matching at the interface level have different BlockAPI() functions.

@lidel
Copy link
Member

lidel commented May 15, 2023

@AustinFoss are you still experiencing this? We've been refactoring a lot of libraries and moving things around last quarter, it works now, maybe you were unlucky month ago?

If the issue si still present, mind sending your go.mod file from kubo-as-a-library?

ps. kubo-as-a-library is a legacy example, we now have a more composable SDK at https://github.com/ipfs/boxo, which may serve you bit better

@lidel lidel added need/author-input Needs input from the original author and removed topic/docs-ipfs Topic docs-ipfs labels May 15, 2023
@aschmahmann aschmahmann added P2 Medium: Good to have, but can wait until someone steps up and removed need/triage Needs initial labeling and prioritization labels May 22, 2023
@github-actions
Copy link

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

@AustinFoss
Copy link
Author

Seems you are correct and I was just a little unlucky with my timing. Created a fresh go working directory and copy pasted the main.go file from the this repo's /docs/examples/kubo-as-alibrary folder to my fresh directory. Ran go mod init <my-project>, go mod tidy, and changed the path variables at lines 227 & 228; works just as intended now without needing to be part of this parent repo.

Closing this issue.

Per your recommendation of boxo; yes I came across it at the time of writing this but at the time I just wanted an existing implementation that had already been tested and just tweak the libp2p part of it, and not build my own implementation from scratch which is what boxo seems to be. From it's README page, "A library for building IPFS applications and implementations." Will investigate boxo a little more as time allows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/stale need/author-input Needs input from the original author P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
Development

No branches or pull requests

3 participants