Commit Graph

384 Commits

Author SHA1 Message Date
Joonas Koivunen
f7680c4907 fix: use struct instead of tuple 2020-08-26 17:15:29 +03:00
ljedrz
be8b113534 refactor: use StringSerialized in /dht queries
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-26 12:33:05 +02:00
ljedrz
ef12cb8e31 fix: fix the /dht/provide conformance tests
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-26 11:24:29 +02:00
ljedrz
d91976ffb3 fix: directly use Cid in Ipfs::{get_providers, provide}
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-26 11:24:29 +02:00
Joonas Koivunen
9ac4486cff refactor: replace String error with BlockError 2020-08-25 17:02:48 +03:00
Joonas Koivunen
cd63a3a4b5 refactor: move the non-path test cases over to ipfs
this introduces duplication between the two sites but I think it's quite
tolerable and at least more favourable than living in lockstep.
2020-08-25 17:02:48 +03:00
Joonas Koivunen
b6e21ab17a refactor: drop unused hex dependency 2020-08-25 17:02:48 +03:00
Joonas Koivunen
ad69ef6d6f refactor: use hex_literal instead of hex::decode 2020-08-25 17:02:48 +03:00
Joonas Koivunen
e18c5d9f25 refactor: move one test case 2020-08-25 17:02:48 +03:00
Joonas Koivunen
f7f5a3cd09 refactor: move refs operation from ipfs-http 2020-08-25 17:02:48 +03:00
Joonas Koivunen
055fe8208e fix: check for unique nodes before queueing 2020-08-25 15:16:02 +03:00
Joonas Koivunen
771562aea6 refactor: remove confusing ResolvedNode methods
removes:

 - `fn destination(&self) -> Option<&Cid>`
 - `fn cid(&self) -> &Cid`
2020-08-25 14:07:29 +03:00
Joonas Koivunen
e2efa5236a doc: suggestions from code review
Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
2020-08-25 14:07:29 +03:00
Joonas Koivunen
2cf1192101 fix: return NotImplemented instead of panic 2020-08-25 12:36:37 +03:00
Joonas Koivunen
c2323b8b7e fix: pass the ".cat should error on unknown path" test again 2020-08-25 12:36:37 +03:00
Joonas Koivunen
e04dd9a6f0 feat: propagate path resolving to ipfs::unixfs::cat level
solved this wrong by isolating it first at http level, however now at
the ipfs::unixfs::cat level the http implementation is looking small as
it should be.

touched some error types and converted them to thiserror.
2020-08-25 12:36:37 +03:00
Joonas Koivunen
32b2553a89 fix: propagate dag errors to ipfs-http as well 2020-08-25 12:36:37 +03:00
Joonas Koivunen
5757a38cda chore: clippy 2020-08-25 12:36:37 +03:00
Joonas Koivunen
8df4be9d94 doc: refresh comments on cat 2020-08-25 12:36:37 +03:00
Joonas Koivunen
7c3ef132a8 chore: remove migrated resolving test cases 2020-08-25 12:36:37 +03:00
Joonas Koivunen
40914a7209 test: migrate resolving invalid list index case 2020-08-25 12:36:37 +03:00
Joonas Koivunen
c66cfe3136 chore: delete already migrated resolving test 2020-08-25 12:36:37 +03:00
Joonas Koivunen
efcfd510e2 feat: local resolving via http
sadly the test doesnt seem to work against jsipfs over http, so it
cannot be enabled, updated the skipped comment though.
2020-08-25 12:36:37 +03:00
Joonas Koivunen
51f3b072eb refactor: migrate from walk_path to dag::resolve
phew, big milestone here. still need to migrate the rest of the tests
but all is looking good.
2020-08-25 12:36:37 +03:00
Joonas Koivunen
358f800bdd refactor: replace walk_paths with ipfs::dag::resolve
zero new test errors ...
2020-08-25 12:36:37 +03:00
Joonas Koivunen
01483fa760 refactor: use more stringserialized in root_files 2020-08-25 12:35:51 +03:00
Joonas Koivunen
02dd734fd9 refactor: replace walk_path in favor of resolve
only one error message conformance test failing so far.
2020-08-25 12:35:51 +03:00
Joonas Koivunen
981a67d781 refactor: use ipfs.dag().resolve in http
perhaps the error message requirements have changed, since this worked
right away? aah nope, they must concern other uses of walk_path. well,
this passes the tests either way.
2020-08-25 12:35:51 +03:00
Joonas Koivunen
1a9d3216b9 refactor: remove IpfsPath::path to allow changing impl details
for example, we might want to just do the splitting manually over a
String. this can be added back, but right now it allowed removal of
unnecessary dependencies at tests.
2020-08-25 12:35:42 +03:00
ljedrz
d84d64cdc9 feat: implement /dht/query (i.e. get_closest_peers)
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-21 13:23:47 +02:00
ljedrz
c4b9358d7e docs: comment on some /dht features
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-21 11:20:13 +02:00
ljedrz
7f7ef95f1f feat: implement /dht/provide
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-21 11:17:14 +02:00
ljedrz
3e2e09ee8c feat: implement /dht/findprovs
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-20 19:18:02 +02:00
ljedrz
a33ee5fe09 feat: make dht/findpeer search the non-local DHT if necessary
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-20 19:05:50 +02:00
bors[bot]
140a86bdcc
Merge #320
320: Implement Ipfs::find_peer and /dht/findpeer r=koivunej a=ljedrz

Builds on https://github.com/rs-ipfs/rust-ipfs/pull/319, only the last 2 commits are new.

Introduces `Ipfs::find_peer` and `/dht/findpeer` that return addresses belonging to the given `PeerId`; if they are connected to already, the values are returned right away, otherwise the local DHT records are checked.

Blocked by https://github.com/rs-ipfs/rust-ipfs/pull/319.



Co-authored-by: ljedrz <ljedrz@gmail.com>
2020-08-20 10:18:15 +00:00
ljedrz
4f2ffe702e
perf: reorder checks to maximize short-circuiting speed
Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
2020-08-20 10:12:00 +02:00
Joonas Koivunen
61b8b6ff1e doc: note reason for strange structuring 2020-08-19 21:56:34 +03:00
Joonas Koivunen
d75ea86685 chore: clippy 2020-08-19 21:50:52 +03:00
Joonas Koivunen
714ecaf093 refactor: remove http IpfsPath and tests 2020-08-19 21:49:07 +03:00
Joonas Koivunen
a57b11ba77 refactor: http: switch to ipfs::path::IpfsPath 2020-08-19 21:49:07 +03:00
Joonas Koivunen
fa652784d5 refactor: remove walk options from http::IpfsPath
definitely wrong place to have those options, and those should have test
cases, since the defaults were ... mixed.
2020-08-19 21:49:07 +03:00
Joonas Koivunen
ba81695178 doc: add FIXME for bad visited usage 2020-08-19 21:49:07 +03:00
Joonas Koivunen
9182ff4d6a doc: update stale FIXME into different FIXME 2020-08-19 21:49:07 +03:00
Joonas Koivunen
3935cf0c49 refactor: remove WalkSuccess::EmptyPath 2020-08-19 21:49:07 +03:00
Joonas Koivunen
ff4037db73 refactor: remove unused pub method 2020-08-19 21:49:06 +03:00
Joonas Koivunen
af8870aaae refactor: remove commented out code 2020-08-19 21:49:06 +03:00
Joonas Koivunen
960ba71a23 refactor: ipfs-http path towards ipfs::path::IpfsPath
first step, lot of commented out code left behind. it was definitely bad
idea to mix the IpfsPath and the iteration over that path.
2020-08-19 21:49:06 +03:00
Joonas Koivunen
a6918d9413 doc: note the refs timeout test case 2020-08-19 21:49:06 +03:00
ljedrz
32815129f1 feat: introduce /dht/findpeer
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-19 16:51:43 +02:00
bors[bot]
34205806a9
Merge #315
315: Use explicit Multiaddr wrappers r=koivunej a=ljedrz

Whether a `Multiaddr` contains `Protocol::P2p` (i.e. essentially `/p2p/PeerId`) or not has a lot of bearing on conformance tests, the internal object and APIs and error-handling. Since it is easy to introduce related human errors, it would be a good idea to enforce some type safety here by introducing 2 wrapper objects: `MultiaddrWoPeerId` and `MultiaddrWithPeerId`.

The extent to which they should be applied (in lieu of `Multiaddr`) is a matter for discussion - in my initial attempt I decided to apply them quite liberally, as it results in more type safety (there are still a few plain `Multiaddr`s left though).

Co-authored-by: ljedrz <ljedrz@gmail.com>
2020-08-18 16:53:28 +00:00
ljedrz
e119d25add feat: add extra /version fields
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-18 14:58:25 +02:00
ljedrz
6e8dff0bb7 feat: utilize the new Multiaddr wrappers 2020-08-17 15:51:26 +02:00
bors[bot]
aaf72c9ed4
Merge #110
110: add: p2p suffixes to multiaddrs from identify r=koivunej a=koivunej

not verified but indirectly used by the conformance tests when dialing a peer with an expected peerid.

Not 100% sure if this should be done, at least long as #105 is done at least to accept the multiaddrs with `/p2p/`.

Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
Co-authored-by: ljedrz <ljedrz@gmail.com>
2020-08-17 09:56:40 +00:00
ljedrz
7e1047f517 docs: note about the P2p protocol suffix returned by Ipfs::identity
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-17 10:43:00 +02:00
ljedrz
a02eedf10b refactor: remove append_p2p in /id
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-17 10:36:36 +02:00
ljedrz
993b80d2d1 fix: disallow Multiaddrs without the P2p protocol
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-14 16:19:56 +02:00
bors[bot]
d2760bb4d5
Merge #294
294: Remove Walker indirection r=koivunej a=c410-f3r

Fixes #200.

By using mutable references instead of taking ownership, the following is now possible:

```rust
ContinuedWalk::Symlink(bytes, _, path, metadata) => {
  ...
}

// Instead of

ContinuedWalk::Symlink(bytes, item) => {
  if let Entry::Metadata(metadata_entry) = item.as_entry() {
    ...
  }
}
```

Co-authored-by: Caio <c410.f3r@gmail.com>
Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
2020-08-14 11:36:11 +00:00
Joonas Koivunen
3f743f2774 chore: cargo fmt 2020-08-14 11:01:58 +02:00
Joonas Koivunen
0a5c730477 add: p2p suffixes to multiaddrs from identify
not verified but indirectly used by the conformance tests when dialing a
peer with an expected peerid.
2020-08-14 11:01:58 +02:00
ljedrz
4154980dbe chore: remove a stray old libipld dep
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-13 18:08:48 +02:00
ljedrz
c930f651fd test: make async tests use only 1 thread
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-13 16:16:20 +02:00
ljedrz
4001e01a44 refactor: remove unused tokio features
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-13 16:15:47 +02:00
ljedrz
9e26bffbba chore: cargo clippy
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-13 16:15:47 +02:00
Caio
457cd428fa Remove inconsistent variants 2020-08-13 10:24:35 -03:00
ljedrz
cc12650d17 feat: allow connecting using /Multiaddr/p2p/PeerId addresses
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-12 12:04:15 +02:00
ljedrz
a9712ef740 chore: put Rust-IPFS contributors as authors
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-11 15:14:43 +02:00
ljedrz
b1bc672559 chore: merge and adapt the libipld dependency
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-10 13:15:11 +02:00
ljedrz
f8674a0504 refactor: remove the generic from IpfsOptions, RepoOptions and SwarmOptions
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-10 11:49:43 +02:00
Joonas Koivunen
aaabc37562 doc: suggestions and notes from code review
Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
2020-08-10 12:04:03 +03:00
Joonas Koivunen
665c0c4f85 doc: comment touch ups 2020-08-10 09:23:11 +03:00
Joonas Koivunen
bfc1bf167c refactor: rename put_file => put_link 2020-08-10 09:22:58 +03:00
Caio
09f44d18f2 Use mutable ref instead of taking ownership
Walker was being moved for each iteration and this was being a problem
for proper `Entry` matching.

Removes `Item` indirection and `continue_walk(self, ...)` is now
`inspect(&mut self, ...)`.
2020-08-09 13:52:14 -03:00
Joonas Koivunen
07c41c0573 fix: tests after going from Infallible => Rejection
the change was made to allow boxing the v0::routes return value.
2020-08-07 21:15:48 +03:00
Joonas Koivunen
a3f27e5b46 fix: move all path matching to v0, box handlers
This patch changes the warp filter boxing strategy so, that:

 1. paths are nested with a "prefix" matcher, if possible
 2. the actual handler for the matched path is boxed
 3. the non implemented but recognized paths are unified

This strategy might be a good compromise between optimizations and
compilation time but such measurements are yet to be done.

Previous boxing strategy ended up being quite unfortunate. Upon adding
the full `/add` implementation, the test cases using GNU binutils linker
or ld 2.33 (ubuntu) started failing failing with a thread overflowing
its stack.

Most of the stack frames were warp filters for matching the path. This
happened because the combine! macro used in http/src/v0.rs boxed
(mostly) each filter, meaning the compiler could never see through any
of the and requiring enough many frames at runtime to cause a stack
overflow.

An alternative of opt-level = 1 turned out to be easy and simple and was
explored in #293 while this solution was being searched for. The
downside is increased compilation time.
2020-08-07 21:07:11 +03:00
Joonas Koivunen
e38c1ff04c refactor: try splitting the huge func 2020-08-07 15:06:55 +03:00
Joonas Koivunen
fdc5f8aa84 refactor: make PostOrderIterator 'static
kind of forgot the String and Vec<u8> while trying to impl the Iterator
trait to return non-static values.
2020-08-07 15:06:55 +03:00
Joonas Koivunen
5d8b124367 doc: suggestions from code review
Thanks to ljedrz for the many many fixes.

Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
2020-08-07 15:06:55 +03:00
Joonas Koivunen
dc2c0217b9 feat: /add?progress=true
adds the progress reporting, which is a progress notification to the
response stream on every block write *in addition to* a notification
*after* the file has been read (order with the `Added` message doesn't
seem to have been specified).
2020-08-07 15:06:55 +03:00
Joonas Koivunen
5534fef2b8 refactor: wrap_in_directory => wrap_with_directory
just aligning the terminology and trying not to invent new terms.
2020-08-07 15:06:55 +03:00
Joonas Koivunen
14112c3dca feat: /add?wrap_with_directory=true
previous implementation included "defaulting the name for the wrapper
dir" which was extra and not expected by the interface tests.
2020-08-07 15:06:55 +03:00
Joonas Koivunen
65acedae1d fix: normalize prefix slash away to enable more tests 2020-08-07 15:06:55 +03:00
Joonas Koivunen
4077de1a0f fix: report adderrors so that js-ipfs-http-client errors
the mechanism is to just push a new line of MessageResponse. it's a
hack, but at least the js-ipfs-http-client fails.
2020-08-07 15:06:55 +03:00
Joonas Koivunen
57737b49c6 refactor: detupleify into (Owned)?TreeNode 2020-08-07 15:06:55 +03:00
Joonas Koivunen
548dbe2873 chore: appease clippy
single while let Some(_) = ... changed to is_some().
2020-08-07 15:06:55 +03:00
Joonas Koivunen
bb9555b14e doc: explain anyhow dependency 2020-08-07 15:06:55 +03:00
Joonas Koivunen
f0bb5b41fd feat: create empty directories without metadata
this is the go-ipfs 0.5 level support for add and directories. next up
will be parsing the headers as unixfsv1.5 metadata and using those with
the directories *and* files.
2020-08-07 15:06:55 +03:00
Joonas Koivunen
ccd6bbe248 feat: build directory trees on /add 2020-08-07 15:06:53 +03:00
Joonas Koivunen
c59a4cbe22 refactor: try make /add streaming 2020-08-07 15:05:05 +03:00
ljedrz
d2016f0193 fix: use tokio::test in http instead of its async_std counterpart
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-07 09:27:15 +02:00
bors[bot]
b99288b7b1
Merge #290
290: Some maintenance r=koivunej a=ljedrz

Some maintenance work so as not to conflict too much with the pending PRs:
- depend on cid instead of libipld where only Cid is used
- update the `domain` dep (big `Cargo.lock` wins)

cc #75 

Co-authored-by: ljedrz <ljedrz@gmail.com>
2020-08-06 13:23:45 +00:00
ljedrz
f5f6790062 chore: depend on cid instead of libipld where only Cid is used
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-08-06 11:38:27 +02:00
Joonas Koivunen
5b6b5ddb1b fix: update async-stream to 0.3
this uses the rust 1.45 features to remove recursion inside the macro.
great for #284 which adds even more complicated async-stream(s).
2020-08-06 11:10:07 +03:00
Caio
94d9b0a358 Future-proof unused dependencies 2020-08-01 13:44:27 -03:00
Caio
d3bd3f649f Use default-features = false where applicable 2020-08-01 13:29:48 -03:00
bors[bot]
c6b68cc0fa
Merge #272
272: Split Entry into two different enums to remove unnecessary expects r=koivunej a=c410-f3r

Second take on #200 

`Entry` is now composed of `Bucket(...)` and `Metadata(MetadataEntry { ... })` to separate things that have and doesn't have metadata, which avoids returning optional values derived from a single entry-point.

Next PR will address the newly introduced double matching while iterating over `continue_walk` but it will require deeper logical changes.

Co-authored-by: Caio <c410.f3r@gmail.com>
2020-07-31 12:39:16 +00:00
Caio
1f8cd25fd9 Split Entry into two different enums 2020-07-31 08:39:47 -03:00
ljedrz
e820e7a5e8 feat: keep a node's Span instead of its name
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-30 17:32:25 +02:00
ljedrz
0abe1b4aa4 refactor: improve node init in some tests
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-30 15:59:14 +02:00
ljedrz
0140c673b8 feat: attach tracing to nodes
Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-30 14:53:38 +02:00
ljedrz
a284c1f841 feat: replace log with tracing
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-29 14:50:00 +02:00
ljedrz
3b6ad52d85 chore: update remaining deps
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-28 13:44:45 +02:00
bors[bot]
f60ac1a8c2
Merge #267
267: ci: use vcpkg for openssl on windows r=ljedrz a=koivunej

Hoping to find something to help with #261:
 - switch to using [lukka/run-vcpkg](https://github.com/lukka/run-vcpkg)
 - get rid of the llvm dependency on windows (it was not needed)
 - update openssl dep to 0.10.30

Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
2020-07-28 10:50:00 +00:00
Joonas Koivunen
2bd1f588a0 chore: update openssl dep 2020-07-28 13:34:25 +03:00
bors[bot]
9e491a68f3
Merge #259
259: Multihash-based repo r=koivunej a=ljedrz

We currently have an ad-hoc `Cid`-upgrading mechanism in place for the legacy `v0` version that is complicated and error-prone; when working on the `SubscriptionRegistry` I had to disable some of those upgrades, but some of them were still applied in the `Repo` (and necessary in order for the conformance tests to pass), making it hard to work on further functionalities like content discovery.

The solution I came up with is to introduce a `RepoCid` wrapper in order to make the keys in `Repo` objects operate on the associated `Multihash` instead of the whole `Cid`. Changing them to plain `Multihash`es wouldn't work, as we are still expected to return `Cid`s for the purposes of e.g. `Ipfs::local_refs` and I'm pretty sure some of the conformance tests still expect the full `Cid` to be available.

The only drawback is some extra `clone()`ing, but the improvement in code clarity and the unblocking of further changes is well worth it. This change also simplifies one of our conformance test patches (local refs).

~~I'm marking this PR as a draft in hopes that I can still come up with some solution to the extra cloning.~~ This is hard; I'm not able to do this at the moment, but this shouldn't be a blocker.

Co-authored-by: ljedrz <ljedrz@gmail.com>
2020-07-28 07:30:09 +00:00
Caio
1107b29114 Rustfmt 2020-07-27 13:16:54 -03:00
Caio
e42b88c6a6 Use async macro for tests 2020-07-27 13:00:40 -03:00
ljedrz
7201b1b82f fix: adjust test_inner_local
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-23 13:58:49 +02:00
ljedrz
b41490fe31 fix: classic Default::default() fun plus remove explicit kad protocol names
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-22 15:47:25 +02:00
ljedrz
ff1765ba10 fix: remove unused params in Node::new and IpfsOptions::inmemory_with_generated_keys
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-22 15:35:25 +02:00
ljedrz
e2297fd53a fix: update a few tests
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-22 13:31:46 +02:00
ljedrz
3bb0a65e04 feat: add and test peer discovery
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-22 12:00:56 +02:00
ljedrz
cc26f40d14 feat: update libp2p again
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-21 14:50:06 +02:00
ljedrz
88c7219790 feat: update some dependencies
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-21 10:31:55 +02:00
Joonas Koivunen
d20a84b164 add: at least some shutdown logging 2020-07-20 13:36:09 +03:00
bors[bot]
d207d1aac6
Merge #240
240: Initial file add r=koivunej a=koivunej

Adds initial file adding through `/add` interface. Does very little of else.

Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
2020-07-16 07:49:14 +00:00
Joonas Koivunen
eb58d7b898 fix: single file add test case 2020-07-16 10:18:07 +03:00
Joonas Koivunen
4c58cfc12b refactor: learn about the /add progress, document 2020-07-14 17:15:28 +03:00
Joonas Koivunen
63056a5d82 fix: clippy, avoid a clone 2020-07-14 17:13:49 +03:00
Joonas Koivunen
152086f146 fix: hook the /add impl up 2020-07-14 16:50:25 +03:00
Joonas Koivunen
d54b3b78fa chore: minor reformatting for multipart body 2020-07-14 16:09:19 +03:00
Joonas Koivunen
cfec7584b6 feat: single file /add
doesnt really handle anything gracefully yet.
2020-07-14 16:09:02 +03:00
ljedrz
23ee954bc1 perf: don't use format! where to_string() is enough
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-07-13 15:43:42 +02:00
Joonas Koivunen
a890964a39 chore: use released mpart-async 2020-07-10 09:31:09 +03:00
bors[bot]
4e6fbdbc58
Merge #233
233: Add http timeouts r=ljedrz a=koivunej

Related to #228, this adds timeout handling to:

 * `block/get`
 * `dag/resolve`
 * `refs` (partial)
 * `cat` (partial)
 * `get` (partial)

Partial means only the initial step of at minimum path walking has the timeout. We cannot yet return errors from streamed bodies because of the lack of `Trailer` support in hyper, so no "request timeout" is enforced once we get to streaming the body.

Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
2020-07-09 15:15:39 +00:00
Joonas Koivunen
f75af14d3f
doc: fix typos
Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
2020-07-09 18:13:49 +03:00
Joonas Koivunen
d00eb829f9 refactor: simplify maybe_timeout 2020-07-09 18:12:48 +03:00
Joonas Koivunen
a7e10a17d8 doc: StringSerialized, add deref(mut)? 2020-07-09 17:52:47 +03:00
Joonas Koivunen
741d81a7ba refactor: inline StatResponse 2020-07-09 17:31:16 +03:00
Joonas Koivunen
2034806e98 refactor: unify "GetQuery" + "StatQuery" = GetStatOptions 2020-07-09 17:29:52 +03:00
Joonas Koivunen
c43b9c6306 feat: naive timeout (with FIXMEs) for /get and /cat
the issue is similar to with refs, we dont have anything overarching the
whole request.
2020-07-09 16:30:49 +03:00
Joonas Koivunen
a1b6e3d594 feat: timeout on initial refs get_blocks 2020-07-09 16:15:15 +03:00
Joonas Koivunen
603a15a6c4 feat: timeout on dag/resolve 2020-07-09 16:14:40 +03:00
Joonas Koivunen
62e0986c41 feat: timeout on block/stat
this wasn't actually needed to pass the test, unsure why.
2020-07-09 14:17:41 +03:00
Joonas Koivunen
fbe90ab8ec feat: timeout on block/get 2020-07-09 14:15:44 +03:00
Joonas Koivunen
fe584f3229 add: maybe timeouted wrapper 2020-07-09 14:15:21 +03:00
Joonas Koivunen
40c7b414e3 add: serde Display/FromStr wrapper
not sure why this isn't included in serde?
2020-07-09 14:14:23 +03:00
Joonas Koivunen
398cc3d0b7 refactor: delay boxing after cid generation
boxing reallocates and cid generation can fail. also added comments.

Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
2020-07-09 11:49:24 +03:00
bors[bot]
e37c9ab8d5
Merge #231
231: Streaming multiparts: pubsub r=ljedrz a=koivunej

This was seen originally but at least it seemed some months ago that there wasn't a way to process multiparts streaming. Luckily the older js-ipfs-http-client puts the message in query. Later versions related to #228 use multipart bodies, but the topic is still a query argument.

Depends on #230.

 * Adds test for the older query part message parsing
 * Uses `&'static str` instead of `&'static [u8]` (fixes error messages)

The latest version should leave us failing only the conformance tests related to:

* pinning
* `?timeout=<not sure what unit>`
  * refs
  * cat
  * get
  * block/get
  * dag/get
* wantlist

This is:

```
  146 passing (3m)
  21 pending
  8 failing
```


Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
2020-07-09 08:27:56 +00:00
bors[bot]
c3b92c7640
Merge #230
230: Streaming multiparts at block/put and dag/put r=ljedrz a=koivunej

Supercedes #225 to cover `dag/put`. I'll close the earlier and keep this as a draft while the temp git dependency is in place.

This allows accepting multipart bodies without Content-Length header by using mpart-async. Uploads are limited to 1MB.

As minor fixes this includes checking `dag/put?input-enc=raw` as we don't support any other input-enc at the moment (rust-ipld could read dag-json, this was implemented during phase1 already).

As more minor fixes this includes transformation of LengthRequired rejection to "Missing header: content-length" instead of "UNHANDLED REJECTION".

Fix is needed for #228.

Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
2020-07-09 08:04:44 +00:00
Joonas Koivunen
7498e7ebda doc: remove unneeded allows, comments 2020-07-08 22:10:55 +03:00
Joonas Koivunen
ce939c3036 fix: wanted error for missing pubsub message 2020-07-08 21:34:13 +03:00
Joonas Koivunen
1c9b31cf76 fix: get pubsub/pub message from multipart body 2020-07-08 21:09:54 +03:00
Joonas Koivunen
6ddd7774ea fix: bad use of [u8] where str would do 2020-07-08 20:33:13 +03:00
Joonas Koivunen
7637874087 refactor: reorder pub fn before inner impl 2020-07-08 19:42:47 +03:00
Joonas Koivunen
6f2bf990cb fix: check input-enc in dag/put
this is minor change but good for interop. the conformance tests only
exercise the input-enc=raw as js-ipfs-http-client does most of the heavy
work. not checking input-enc could end up someone trying to put a json
dag document expecting it to be transformed to cbor, which we currently
do not support.
2020-07-08 19:26:01 +03:00
Joonas Koivunen
fef741c750 fix: allow multipart bodies without content-len in dag/put 2020-07-08 19:25:43 +03:00
Joonas Koivunen
4101383855 refactor: move try_only_named.. to support 2020-07-08 19:24:17 +03:00
Joonas Koivunen
087776bda1 refactor: try_only_named_multipart out of put_block 2020-07-08 19:17:58 +03:00
Joonas Koivunen
06ba40e8f2 fix: add descriptive error for LengthRequired 2020-07-08 16:03:10 +03:00
Joonas Koivunen
0a9ee274ca temp: upgrade to mpart-async with fix 2020-07-08 13:52:01 +03:00