Return error for excluded secondary-index keys (#17193)

* Add runtime helpers to check secondary indexes for key

* Add custom rpc error

* Check secondary-index key inclusion in rpc

* Clone complete AccountSecondaryIndexes into rpc to avoid bank query
This commit is contained in:
Tyera Eulberg
2021-05-13 15:04:21 -06:00
committed by GitHub
parent 3dbc7744ab
commit 27004f1b76
5 changed files with 85 additions and 36 deletions

View File

@ -715,6 +715,10 @@ impl Accounts {
.0
}
pub fn account_indexes_include_key(&self, key: &Pubkey) -> bool {
self.accounts_db.account_indexes.include_key(key)
}
pub fn load_all(&self, ancestors: &Ancestors) -> Vec<(Pubkey, AccountSharedData, Slot)> {
self.accounts_db.scan_accounts(
ancestors,

View File

@ -4246,6 +4246,10 @@ impl Bank {
.load_by_index_key_with_filter(&self.ancestors, index_key, filter)
}
pub fn account_indexes_include_key(&self, key: &Pubkey) -> bool {
self.rc.accounts.account_indexes_include_key(key)
}
pub fn get_all_accounts_with_modified_slots(&self) -> Vec<(Pubkey, AccountSharedData, Slot)> {
self.rc.accounts.load_all(&self.ancestors)
}