Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliotpaez/solana-balanced-client
https://github.com/juliotpaez/solana-balanced-client
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/juliotpaez/solana-balanced-client
- Owner: juliotpaez
- License: mit
- Created: 2022-11-16T15:59:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T16:06:57.000Z (about 2 years ago)
- Last Synced: 2024-09-30T07:06:11.718Z (3 months ago)
- Language: Rust
- Size: 34.2 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Solana Balanced Client
This is a wrapper over the `RpcClient` of solana-client crate. It provides the ability to balance the requests between
multiple RPC endpoints taking into account their limits.## Usage
```rust
fn main() {
let default_rpc = Arc::new(RpcClient::new(
"https://api.mainnet-beta.solana.com".to_string(),
));
let your_rpc = Arc::new(RpcClient::new("".to_string()));
let client = SolanaClient::new_with_default(your_rpc).add_rpc(
SolanaClientRpc::new(quicknode_rpc)
// Credits / month limits.
.add_limit(
SolanaClientRateLimit::new(
30 * 24 * 60 * 60 * 1000, /* 30 days */
1_000, /* credits per month */
1, /* default cost in credits for endpoints */
)
// Ignore those endpoints that should be handled in this limit.
.ignore_endpoint(RpcRequest::GetHealth)
// List of all endpoints whose credits are different than the default value.
.add_endpoint_amount(RpcRequest::GetAccountInfo, 2)
.add_endpoint_amount(RpcRequest::GetMultipleAccounts, 10)
)
// Requests / second limit.
.add_limit(SolanaClientRateLimit::new(
1000, /* 1 second */
10, /* 10 requests per second */
1, /* all requests count the same */
)),
);
// ...
}
```You can see more examples in the [`examples`](examples) directory.
# License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.