Skip to content

Commit

Permalink
fix(velas-ccount): Fix velas account storage key finding method.
Browse files Browse the repository at this point in the history
  • Loading branch information
vldm committed Oct 12, 2021
1 parent 71481d9 commit b36f753
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4030,10 +4030,12 @@ pub mod rpc_full {
);

let accounts = storages
.expect("velas account operational index to be activated")
.into_iter()
.flatten()
.flat_map(|(storage, _)| meta.get_velas_accounts_by_storage_key(&bank, storage))
.flatten();
.flat_map(|(storage, _)| {
meta.get_velas_accounts_by_storage_key(&bank, storage)
.expect("velas account storage index to be activated")
});
debug!(
"get_velas_accounts_by_operational_key velas accounts {:?}",
accounts
Expand Down
6 changes: 4 additions & 2 deletions programs/velas-account-program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ pub struct VAccountInfo {
}

impl VAccountInfo {
const SUFFIX_OPERATIONAL_STORAGE: &'static [u8] = b"operationals";

pub fn find_storage_key(&self, vaccount: &Pubkey) -> Pubkey {
Pubkey::find_program_address(
&[
&vaccount.to_bytes(),
b"storage",
&self.programs_storage_nonce.to_le_bytes(),
Self::SUFFIX_OPERATIONAL_STORAGE,
&self.operational_storage_nonce.to_le_bytes(),
],
&crate::id(),
)
Expand Down

0 comments on commit b36f753

Please sign in to comment.