Rename struct to imported name (#22814)

* use imported RpcResponse

* Remove extra map method

* rename result to accounts

* fmt
This commit is contained in:
Kirill Fomichev 2022-02-08 22:01:40 +03:00 committed by GitHub
parent dcd4ea9111
commit 541b5a4826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -116,7 +116,7 @@ const MAX_RPC_EPOCH_CREDITS_HISTORY: usize = 5;
fn new_response<T>(bank: &Bank, value: T) -> RpcResponse<T> {
let context = RpcResponseContext { slot: bank.slot() };
Response { context, value }
RpcResponse { context, value }
}
/// Wrapper for rpc return types of methods that provide responses both with and without context.
@ -412,7 +412,8 @@ impl JsonRpcRequestProcessor {
self.get_filtered_program_accounts(&bank, program_id, filters)?
}
};
let result = if program_id == &spl_token_id() && encoding == UiAccountEncoding::JsonParsed {
let accounts = if program_id == &spl_token_id() && encoding == UiAccountEncoding::JsonParsed
{
get_parsed_token_accounts(bank.clone(), keyed_accounts.into_iter()).collect()
} else {
keyed_accounts
@ -425,9 +426,9 @@ impl JsonRpcRequestProcessor {
})
.collect::<Result<Vec<_>>>()?
};
Ok(result).map(|result| match with_context {
true => OptionalContext::Context(new_response(&bank, result)),
false => OptionalContext::NoContext(result),
Ok(match with_context {
true => OptionalContext::Context(new_response(&bank, accounts)),
false => OptionalContext::NoContext(accounts),
})
}
@ -754,7 +755,7 @@ impl JsonRpcRequestProcessor {
let bank = self.bank(config.commitment);
if let Some((slot, accounts)) = self.get_cached_largest_accounts(&config.filter) {
Ok(Response {
Ok(RpcResponse {
context: RpcResponseContext { slot },
value: accounts,
})