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

Refactor + Block store #1

Merged
merged 36 commits into from
Oct 9, 2023
Merged

Refactor + Block store #1

merged 36 commits into from
Oct 9, 2023

Conversation

n8maninger
Copy link
Member

@n8maninger n8maninger commented Oct 6, 2023

Basically a huge refactor that also happens to add a chunk database to store each chunk and offset 😅

You can use [POST] /api/cid/calculate to test the chunk calculation and compare it with IPFS desktop. [0] is always the root CID and should have offset = 0, length = upload length.

A major change to the API is that you no longer have to load the whole file into memory. The downside is it can't automatically use the CID as the renterd object key. You can either precalculate it or use an arbitrary key. The local db maps the key back to the CID after upload. Maybe in the future, the file should be uploaded to the renterd first (S3/regularly) then manually pinned to the gateway.

cmd/siapfsd/ipfs.go Outdated Show resolved Hide resolved
cmd/siapfsd/main.go Outdated Show resolved Hide resolved
cmd/siapfsd/main.go Outdated Show resolved Hide resolved
http/ipfs.go Show resolved Hide resolved
http/ipfs.go Show resolved Hide resolved
http/ipfs.go Outdated Show resolved Hide resolved
@n8maninger
Copy link
Member Author

n8maninger commented Oct 7, 2023

@alexfreska all of the necessary IPFS config has been moved into the yaml file. You can delete the ipfs folder and there's no need to run init.

api:
  address: :8081
  password: sia is cool
renterd:
  address: http://localhost:9980/api/worker
  password: sia is extra cool
  bucket: ipfs
ipfs:
  gatewayAddress: :8080 # gateway URL
  listenAddresses:
    - /ip4/0.0.0.0/tcp/4001 # the listen address for bitswap. Since no announce addresses are configured, no bits will be swapped
  fetchRemote: true # true if you want to download files that aren't pinned

Gateway Endpoints:

[GET] /ipfs/:cid (if fetchRemote is true, will try to download from IPFS)

API Endpoints:

[POST] /api/upload/:cid (request body is the raw file to upload, CID is technically arbitrary)
[POST] /api/pin/:cid (request body is empty, file will be downloaded from IPFS and pinned to the node)
[POST] /api/cid/calculate (request body is the raw file to upload, calculates the blocks and root CID)

Copy link
Member

@alexfreska alexfreska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n8maninger are you able to upload? I get a status 308 from the renterd worker client here: https://github.com/SiaFoundation/renterd/blob/master/worker/client.go#L208

@n8maninger
Copy link
Member Author

n8maninger commented Oct 9, 2023

@n8maninger are you able to upload? I get a status 308 from the renterd worker client here: https://github.com/SiaFoundation/renterd/blob/master/worker/client.go#L208

308 is a permanent redirect. What are your renterd settings?

@alexfreska
Copy link
Member

alexfreska commented Oct 9, 2023

@n8maninger

308 is a permanent redirect. What are your renterd settings?

api:
  address: :8081
  password: <password>
renterd:
  address: http://arequipa.sia.tech/api/worker
  password: <password>
  bucket: ipfs
ipfs:
  gatewayAddress: :8080
  listenAddresses:
    - /ip4/0.0.0.0/tcp/4001
  fetchRemote: true

@n8maninger
Copy link
Member Author

n8maninger commented Oct 9, 2023

@n8maninger

308 is a permanent redirect. What are your renterd settings?

api:
  address: :8081
  password: <password>
renterd:
  address: http://arequipa.sia.tech/api/worker
  password: <password>
  bucket: ipfs
ipfs:
  gatewayAddress: :8080
  listenAddresses:
    - /ip4/0.0.0.0/tcp/4001
  fetchRemote: true

Shouldn't that be https://arequipa.sia.tech/api/worker?

Copy link
Member

@alexfreska alexfreska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@n8maninger n8maninger merged commit 748fcfa into main Oct 9, 2023
2 checks passed
@n8maninger n8maninger deleted the nate/add-blockstore branch October 9, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants