Skip to content

Commit

Permalink
Move MatchAccountOwnerError from append_vec to accounts_file (solana-…
Browse files Browse the repository at this point in the history
…labs#34187)

#### Problem
MatchAccountOwnerError currently belongs to append_vec.

However, it is a public error type that is also required by other AccountsFile
implementations such as TieredStorageFile.

#### Summary of Changes
Move MatchAccountOwnerError from append_vec to accounts_file.
  • Loading branch information
yhchiang-sol authored Nov 21, 2023
1 parent f2878c0 commit db2444b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
AccountStorage, AccountStorageStatus, ShrinkInProgress,
},
accounts_cache::{AccountsCache, CachedAccount, SlotCache},
accounts_file::{AccountsFile, AccountsFileError},
accounts_file::{AccountsFile, AccountsFileError, MatchAccountOwnerError},
accounts_hash::{
AccountHash, AccountsDeltaHash, AccountsHash, AccountsHashKind, AccountsHasher,
CalcAccountsHashConfig, CalculateHashIntermediate, HashStats, IncrementalAccountsHash,
Expand All @@ -54,8 +54,7 @@ use {
get_ancient_append_vec_capacity, is_ancient, AccountsToStore, StorageSelector,
},
append_vec::{
aligned_stored_size, AppendVec, MatchAccountOwnerError, APPEND_VEC_MMAPPED_FILES_OPEN,
STORE_META_OVERHEAD,
aligned_stored_size, AppendVec, APPEND_VEC_MMAPPED_FILES_OPEN, STORE_META_OVERHEAD,
},
cache_hash_data::{CacheHashData, CacheHashDataFileReference},
contains::Contains,
Expand Down
10 changes: 9 additions & 1 deletion accounts-db/src/accounts_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
StorableAccountsWithHashesAndWriteVersions, StoredAccountInfo, StoredAccountMeta,
},
accounts_hash::AccountHash,
append_vec::{AppendVec, AppendVecError, MatchAccountOwnerError},
append_vec::{AppendVec, AppendVecError},
storable_accounts::StorableAccounts,
tiered_storage::error::TieredStorageError,
},
Expand Down Expand Up @@ -40,6 +40,14 @@ pub enum AccountsFileError {
TieredStorageError(#[from] TieredStorageError),
}

#[derive(Error, Debug, PartialEq, Eq)]
pub enum MatchAccountOwnerError {
#[error("The account owner does not match with the provided list")]
NoMatch,
#[error("Unable to load the account")]
UnableToLoad,
}

pub type Result<T> = std::result::Result<T, AccountsFileError>;

#[derive(Debug)]
Expand Down
10 changes: 1 addition & 9 deletions accounts-db/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
AccountMeta, StorableAccountsWithHashesAndWriteVersions, StoredAccountInfo,
StoredAccountMeta, StoredMeta, StoredMetaWriteVersion,
},
accounts_file::{AccountsFileError, Result, ALIGN_BOUNDARY_OFFSET},
accounts_file::{AccountsFileError, MatchAccountOwnerError, Result, ALIGN_BOUNDARY_OFFSET},
accounts_hash::AccountHash,
storable_accounts::StorableAccounts,
u64_align,
Expand Down Expand Up @@ -96,14 +96,6 @@ impl<'append_vec> Iterator for AppendVecAccountsIter<'append_vec> {
}
}

#[derive(Error, Debug, PartialEq, Eq)]
pub enum MatchAccountOwnerError {
#[error("The account owner does not match with the provided list")]
NoMatch,
#[error("Unable to load the account")]
UnableToLoad,
}

/// References to account data stored elsewhere. Getting an `Account` requires cloning
/// (see `StoredAccountMeta::clone_account()`).
#[derive(PartialEq, Eq, Debug)]
Expand Down

0 comments on commit db2444b

Please sign in to comment.