Skip to content

Commit a8ab194

Browse files
committed
Merge #558: jsonrpc: Add async support
0aa7803 Add async support to jsonrpc (Jamil Lambert, PhD) 7302ebd Change Debug impl to local Client (Jamil Lambert, PhD) 7d556f9 Remove fuzz related sections (Jamil Lambert, PhD) e62b044 Copy jsonrpc client and bitreq_http for async. (Jamil Lambert, PhD) c16f4b5 Round timeouts to whole seconds (Jamil Lambert, PhD) Pull request description: Pulled out of #505 and polished. The aim is to add async support without breaking existing sync downstream. This includes keeping the reexports of the current sync `Client` at the crate root. ACKs for top commit: apoelstra: utACK 0aa7803 Tree-SHA512: d0a096181668f7656ed3ba8f7d3cf77560a39c6eec2c6ff410627e35ae7d798ef6abe6cd0a467317383a6091c403aded977d095a43f2090a5e359f305e0bf12a
2 parents 6684e2c + 0aa7803 commit a8ab194

9 files changed

Lines changed: 768 additions & 3 deletions

File tree

Cargo-minimal.lock

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,94 @@ dependencies = [
371371
"percent-encoding",
372372
]
373373

374+
[[package]]
375+
name = "futures"
376+
version = "0.3.32"
377+
source = "registry+https://github.com/rust-lang/crates.io-index"
378+
checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d"
379+
dependencies = [
380+
"futures-channel",
381+
"futures-core",
382+
"futures-executor",
383+
"futures-io",
384+
"futures-sink",
385+
"futures-task",
386+
"futures-util",
387+
]
388+
389+
[[package]]
390+
name = "futures-channel"
391+
version = "0.3.32"
392+
source = "registry+https://github.com/rust-lang/crates.io-index"
393+
checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d"
394+
dependencies = [
395+
"futures-core",
396+
"futures-sink",
397+
]
398+
399+
[[package]]
400+
name = "futures-core"
401+
version = "0.3.32"
402+
source = "registry+https://github.com/rust-lang/crates.io-index"
403+
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
404+
405+
[[package]]
406+
name = "futures-executor"
407+
version = "0.3.32"
408+
source = "registry+https://github.com/rust-lang/crates.io-index"
409+
checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d"
410+
dependencies = [
411+
"futures-core",
412+
"futures-task",
413+
"futures-util",
414+
]
415+
416+
[[package]]
417+
name = "futures-io"
418+
version = "0.3.32"
419+
source = "registry+https://github.com/rust-lang/crates.io-index"
420+
checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718"
421+
422+
[[package]]
423+
name = "futures-macro"
424+
version = "0.3.32"
425+
source = "registry+https://github.com/rust-lang/crates.io-index"
426+
checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b"
427+
dependencies = [
428+
"proc-macro2",
429+
"quote",
430+
"syn",
431+
]
432+
433+
[[package]]
434+
name = "futures-sink"
435+
version = "0.3.32"
436+
source = "registry+https://github.com/rust-lang/crates.io-index"
437+
checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893"
438+
439+
[[package]]
440+
name = "futures-task"
441+
version = "0.3.32"
442+
source = "registry+https://github.com/rust-lang/crates.io-index"
443+
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
444+
445+
[[package]]
446+
name = "futures-util"
447+
version = "0.3.32"
448+
source = "registry+https://github.com/rust-lang/crates.io-index"
449+
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
450+
dependencies = [
451+
"futures-channel",
452+
"futures-core",
453+
"futures-io",
454+
"futures-macro",
455+
"futures-sink",
456+
"futures-task",
457+
"memchr",
458+
"pin-project-lite",
459+
"slab",
460+
]
461+
374462
[[package]]
375463
name = "getrandom"
376464
version = "0.2.15"
@@ -482,6 +570,7 @@ version = "0.19.0"
482570
dependencies = [
483571
"base64 0.22.1",
484572
"bitreq",
573+
"futures",
485574
"serde",
486575
"serde_json",
487576
"socks",
@@ -981,6 +1070,12 @@ version = "1.3.0"
9811070
source = "registry+https://github.com/rust-lang/crates.io-index"
9821071
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
9831072

1073+
[[package]]
1074+
name = "slab"
1075+
version = "0.4.12"
1076+
source = "registry+https://github.com/rust-lang/crates.io-index"
1077+
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
1078+
9841079
[[package]]
9851080
name = "smallvec"
9861081
version = "1.15.1"

Cargo-recent.lock

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,94 @@ dependencies = [
371371
"percent-encoding",
372372
]
373373

374+
[[package]]
375+
name = "futures"
376+
version = "0.3.32"
377+
source = "registry+https://github.com/rust-lang/crates.io-index"
378+
checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d"
379+
dependencies = [
380+
"futures-channel",
381+
"futures-core",
382+
"futures-executor",
383+
"futures-io",
384+
"futures-sink",
385+
"futures-task",
386+
"futures-util",
387+
]
388+
389+
[[package]]
390+
name = "futures-channel"
391+
version = "0.3.32"
392+
source = "registry+https://github.com/rust-lang/crates.io-index"
393+
checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d"
394+
dependencies = [
395+
"futures-core",
396+
"futures-sink",
397+
]
398+
399+
[[package]]
400+
name = "futures-core"
401+
version = "0.3.32"
402+
source = "registry+https://github.com/rust-lang/crates.io-index"
403+
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
404+
405+
[[package]]
406+
name = "futures-executor"
407+
version = "0.3.32"
408+
source = "registry+https://github.com/rust-lang/crates.io-index"
409+
checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d"
410+
dependencies = [
411+
"futures-core",
412+
"futures-task",
413+
"futures-util",
414+
]
415+
416+
[[package]]
417+
name = "futures-io"
418+
version = "0.3.32"
419+
source = "registry+https://github.com/rust-lang/crates.io-index"
420+
checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718"
421+
422+
[[package]]
423+
name = "futures-macro"
424+
version = "0.3.32"
425+
source = "registry+https://github.com/rust-lang/crates.io-index"
426+
checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b"
427+
dependencies = [
428+
"proc-macro2",
429+
"quote",
430+
"syn",
431+
]
432+
433+
[[package]]
434+
name = "futures-sink"
435+
version = "0.3.32"
436+
source = "registry+https://github.com/rust-lang/crates.io-index"
437+
checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893"
438+
439+
[[package]]
440+
name = "futures-task"
441+
version = "0.3.32"
442+
source = "registry+https://github.com/rust-lang/crates.io-index"
443+
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
444+
445+
[[package]]
446+
name = "futures-util"
447+
version = "0.3.32"
448+
source = "registry+https://github.com/rust-lang/crates.io-index"
449+
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
450+
dependencies = [
451+
"futures-channel",
452+
"futures-core",
453+
"futures-io",
454+
"futures-macro",
455+
"futures-sink",
456+
"futures-task",
457+
"memchr",
458+
"pin-project-lite",
459+
"slab",
460+
]
461+
374462
[[package]]
375463
name = "getrandom"
376464
version = "0.2.15"
@@ -482,6 +570,7 @@ version = "0.19.0"
482570
dependencies = [
483571
"base64 0.22.1",
484572
"bitreq",
573+
"futures",
485574
"serde",
486575
"serde_json",
487576
"socks",
@@ -981,6 +1070,12 @@ version = "1.3.0"
9811070
source = "registry+https://github.com/rust-lang/crates.io-index"
9821071
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
9831072

1073+
[[package]]
1074+
name = "slab"
1075+
version = "0.4.12"
1076+
source = "registry+https://github.com/rust-lang/crates.io-index"
1077+
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
1078+
9841079
[[package]]
9851080
name = "smallvec"
9861081
version = "1.15.1"

jsonrpc/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ default = [ "simple_http", "simple_tcp" ]
2222
simple_http = [ "base64" ]
2323
# A transport that uses `bitreq` as the HTTP client.
2424
bitreq_http = [ "base64", "bitreq" ]
25+
# A transport that uses `bitreq` as the async HTTP client.
26+
bitreq_http_async = [ "base64", "bitreq", "bitreq/async", "client_async" ]
27+
# An async JSON-RPC client implementation.
28+
client_async = []
2529
# Basic transport over a raw TcpListener
2630
simple_tcp = []
2731
# Basic transport over a raw UnixStream
@@ -37,5 +41,8 @@ base64 = { version = "0.22.1", optional = true }
3741
bitreq = { version = "0.3.0", path = "../bitreq", features = ["json-using-serde"], optional = true }
3842
socks = { version = "0.3.4", optional = true}
3943

44+
[dev-dependencies]
45+
futures = "0.3"
46+
4047
[lints.rust]
4148
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(jsonrpc_fuzz)'] }

jsonrpc/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Client {
124124
}
125125
}
126126

127-
impl fmt::Debug for crate::Client {
127+
impl fmt::Debug for Client {
128128
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
129129
write!(f, "jsonrpc::Client(")?;
130130
self.transport.fmt_target(f)?;

0 commit comments

Comments
 (0)