-
Notifications
You must be signed in to change notification settings - Fork 293
Fix fetch_positions_for_owner() to perform batch calls #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
0454f07
fd12d09
7c05710
6d845e2
10bbdd4
781b829
dc57569
3ec4c60
5a4d830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@orca-so/whirlpools-rust": patch | ||
| --- | ||
|
|
||
| Fix fetch_positions_for_owner() to perform batch calls | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ mod pool; | |
| mod position; | ||
| mod swap; | ||
| mod token; | ||
| mod utils; | ||
|
|
||
| #[cfg(test)] | ||
| mod e2e; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use solana_client::nonblocking::rpc_client::RpcClient; | ||
| use solana_sdk::account::Account; | ||
| use solana_sdk::pubkey::Pubkey; | ||
|
|
||
| const DEFAULT_CHUNK_SIZE: usize = 100; | ||
|
|
||
| pub(crate) async fn batch_get_multiple_accounts( | ||
| rpc_client: &RpcClient, | ||
| pubkeys: &[Pubkey], | ||
| chunk_size: Option<usize>, | ||
| ) -> Result<Vec<Option<Account>>, Box<dyn std::error::Error>> { | ||
| let mut results = vec![]; | ||
|
|
||
| for chunk in pubkeys.chunks(chunk_size.unwrap_or(DEFAULT_CHUNK_SIZE)) { | ||
|
||
| let accounts = rpc_client.get_multiple_accounts(chunk).await?; | ||
| results.extend(accounts); | ||
| } | ||
|
|
||
| Ok(results) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need a changeset for the TS sdk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.