| Crates.io | pivx-throttled-jsonrpc |
| lib.rs | pivx-throttled-jsonrpc |
| version | 0.1.0 |
| created_at | 2026-01-03 04:52:57.41385+00 |
| updated_at | 2026-01-03 04:52:57.41385+00 |
| description | Macro-based throttled JSON-RPC client with rate limiting and batching support |
| homepage | https://github.com/DR-BoneZ/throttled-json-rpc-rs |
| repository | https://github.com/DR-BoneZ/throttled-json-rpc-rs |
| max_upload_size | |
| id | 2019611 |
| size | 69,394 |
A macro-based JSON-RPC client generator with built-in rate limiting, concurrency control, and request batching.
Add this to your Cargo.toml:
[dependencies]
pivx-throttled-jsonrpc = "0.1"
use throttled_json_rpc::jsonrpc_client;
jsonrpc_client!(pub struct MyRpcClient {
single:
/// Get block hash by height
pub fn getblockhash(&self, height: u64) -> Result<String>;
/// Get block by hash
pub fn getblock(&self, hash: String, verbosity: u32) -> Result<serde_json::Value>;
});
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = MyRpcClient::new(
"http://localhost:8332".to_string(),
Some("rpcuser".to_string()),
Some("rpcpass".to_string()),
5, // max 5 concurrent requests
10, // max 10 requests per second
0, // no batching (0 = disabled)
);
let block_hash = client.getblockhash(100)?;
let block = client.getblock(block_hash, 1)?;
println!("Block: {:?}", block);
Ok(())
}
For detailed documentation and more examples, visit docs.rs/throttled_json_rpc.
Licensed under the MIT license. See LICENSE for details.
This is a maintained fork of the original throttled-json-rpc-rs crate, modernized for current Rust standards and actively maintained by PIVX Labs.
Contributions welcome! Please open issues or PRs on GitHub.