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

Add batch operation to ipfs block put #3667

Closed
ianopolous opened this issue Feb 8, 2017 · 8 comments
Closed

Add batch operation to ipfs block put #3667

ianopolous opened this issue Feb 8, 2017 · 8 comments
Labels
help wanted Seeking public contribution on this issue kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding status/ready Ready to be worked

Comments

@ianopolous
Copy link
Member

Version information:

go-ipfs version: 0.4.5-rc1-8c07404
Repo version: 5
System version: amd64/linux
Golang version: go1.7.1

Type: Bug

Priority: P2

Description:

The http bulk block.put command seems to only add the first file in the multipart

To reproduce (where file1.txt and file2.txt are two small files):

curl -v -F myPartName1=@file1.txt -F myPartName2=@file2.txt http://localhost:5001/api/v0/block/put
=> {"Key":"QmRfJWuFg328tVnkDfH1WHGuiuy2FbtZyhyNHQSA2dnh68","Size":4}
* Connection #0 to host localhost left intact

So it's only returning the hash of the first file (and presumably only adding the first), and also not closing the connection.

@whyrusleeping
Copy link
Member

The file argument to ipfs block put is not variadic, it only accepts a single input file.

I asked @diasdavid and he thinks this is the correct behaviour.

@daviddias
Copy link
Member

Hey, we also sync'ed up again and we discussed adding a flag for 'batch puts', so that existing API work and batching puts because extra feature, how does that sound?

@ianopolous
Copy link
Member Author

Sorry, somehow I got it in my head that this was already how the api worked because it is using multipart.
Adding a batch option sounds great and would hugely facilitate apps running over a high latency (even interplanetary ;-) ) connection.

@ianopolous
Copy link
Member Author

I may be wrong, but I think it wouldn't even require the batch flag. Existing http api implementations can continue as they are, because they are already using multipart, just with a single file. Updated ones can, include more than one file and parse the resulting stream of json objects.

@mib-kd743naq
Copy link
Contributor

@ianopolous there's the related #3442: HTTP overhead is quite high in the face of many blocks, so a "cli-streamed" solution seemed more appropriate.

A specific example of what a dataset looks like is at https://ipfs.io/ipfs/QmYbb74fCe7pom18nPRw2rKAPMukza63DfQAdHG53WywbW, containing the entire dataset for #3552

@ianopolous
Copy link
Member Author

@diasdavid Having thought more about this and discussed with @whyrusleeping I'm pretty confident this is relatively easy to do without a batch flag (I've also already implemented it in Java for our proxy), and in a backwards compatible way for old http clients.

The key thing is the clients are already using the multipart protocol, but only writing 1 file, so the protocol is the same. The headers for a response may change if there is more than 1 file, but they could (should) remain the same for puts of a single file. This would be bitwise identical with existing behaviour, and as old clients will only ever ask to put 1 file, they will never see any difference.

Currently, the server can't write the first response hash until it's read the first file fully (and there's little point writing the headers before then as the client will have to wait anyway to read the hash), by which point it knows if there is more than 1 file or not and could set the headers accordingly.

@Kubuxu Kubuxu added kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding labels Mar 15, 2017
@whyrusleeping whyrusleeping added the help wanted Seeking public contribution on this issue label Sep 2, 2017
@whyrusleeping
Copy link
Member

Yeah, we should be able to do a batch block put. lets get this written up (and make sure to have a test for api backwards compatibility)

@whyrusleeping whyrusleeping added this to the Ipfs 0.4.12 milestone Sep 2, 2017
@Kubuxu Kubuxu changed the title Bulk block put only adds the first file Add batch operation to ipfs block put Nov 6, 2017
@Kubuxu Kubuxu modified the milestones: Ipfs 0.4.12, go-ipfs 0.4.13 Nov 6, 2017
@jacobheun jacobheun added the status/ready Ready to be worked label May 29, 2020
@Stebalien
Copy link
Member

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

7 participants