Skip to content

Fix contract bug

Luke Champine requested to merge fixapi into master

Found the bug!

Seems like it was actually caused by too many pieces, not too few. The problem was that each piece was being uploaded in parallel, but the actual data -- the io.ReadSeeker -- was shared between them. So their seeks, reads, merkle roots, etc. were being interleaved.

I changed the UploadParams back to just using a filename instead of a generic interface. I don't see a real need to support more than that. Maybe one day we will, but for now this is a lot easier. Each upload opens a separate file handle, so the reads don't conflict. We could potentially optimize this by writing to multiple connections at once, instead of having to read the entire file n times, but it'd be wasted effort since the pieces are eventually going to be erasure-coded anyway.

I also added a naive connection timeout; any time there's a read or write, the timeout is reset to 10 seconds. This should be more than enough time, even for very slow connections. (In case you're worried about large files: they call Read many times on a small buffer, so they shouldn't be in danger of timing out.)

Merge request reports