fix: use the config arg in the get_balance rpc method#547
fix: use the config arg in the get_balance rpc method#547MicaiahReid merged 6 commits intosolana-foundation:mainfrom
Conversation
MicaiahReid
left a comment
There was a problem hiding this comment.
Thanks for the issue! Some small fixes requested.
|
@MicaiahReid I've made the changes |
MicaiahReid
left a comment
There was a problem hiding this comment.
Sorry, should have requested earlier, can we also add some tests for these changes?
crates/core/src/error.rs
Outdated
| pub fn get_balance() -> Self { | ||
| let mut error = Error::internal_error(); | ||
| error.data = Some(json!("Context slot too old")); | ||
| Self(error) | ||
| } |
There was a problem hiding this comment.
Can we remove this error that is no longer being used?
|
@MicaiahReid added some tests that check whether the lmk if anything else is required. Thanks |
|
@MicaiahReid Added config support for the |
Summary
This PR refactors
SurfpoolMinimalRpc::get_balance()to use theconfig: Option<RpcContextConfig>argument, which provides thecommitment: Option<CommitmentConfig>andmin_context_slot: Option<u64>variables, in order to customize the get_balance rpc method furtherWhat Changed
commitmentandmin_context_slotvariables, and providedCommitment::confirmed()(the default earilier) to commitment andNonetomin_context_slotin caseNonecommitmentprovided in config inside themeta.get_rpc_context()in case present, orCommitment::confirmed()otherwisemin_context_slotvalue (if present) to validate thesvm_locker.get_account().slotSurfpoolError::get_balance()method that returns aSurfpoolError::internal_error()witherror.data = "Context slot too old"Context
This change was motivated by an existing comment inside
SurfpoolMinimalRpc::get_balance()that suggested using the config in the function. This PR increases the configurability of the rpc'sget_balancemethod by allowing to provide the commitment level and min_context_slot as argumentsNote
I may or may not have used the
min_context_slotvalue properly, as I've assumed that it's used to validate the valuesvm_locker.get_account().slotand require it to be bigger then then the argument. I'd be happy to change it's use case in case my assumption is wrong. Thanks