(cherry picked from commit 4431080066)
Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
			
			
This commit is contained in:
		@@ -293,7 +293,7 @@ fn filter_signature_result(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
fn filter_program_results(
 | 
					fn filter_program_results(
 | 
				
			||||||
    accounts: Vec<(Pubkey, Account)>,
 | 
					    accounts: Vec<(Pubkey, Account)>,
 | 
				
			||||||
    _program_id: &Pubkey,
 | 
					    program_id: &Pubkey,
 | 
				
			||||||
    last_notified_slot: Slot,
 | 
					    last_notified_slot: Slot,
 | 
				
			||||||
    config: Option<ProgramConfig>,
 | 
					    config: Option<ProgramConfig>,
 | 
				
			||||||
    bank: Option<Arc<Bank>>,
 | 
					    bank: Option<Arc<Bank>>,
 | 
				
			||||||
@@ -301,24 +301,27 @@ fn filter_program_results(
 | 
				
			|||||||
    let config = config.unwrap_or_default();
 | 
					    let config = config.unwrap_or_default();
 | 
				
			||||||
    let encoding = config.encoding.unwrap_or(UiAccountEncoding::Binary);
 | 
					    let encoding = config.encoding.unwrap_or(UiAccountEncoding::Binary);
 | 
				
			||||||
    let filters = config.filters;
 | 
					    let filters = config.filters;
 | 
				
			||||||
 | 
					    let accounts_is_empty = accounts.is_empty();
 | 
				
			||||||
    let keyed_accounts = accounts.into_iter().filter(move |(_, account)| {
 | 
					    let keyed_accounts = accounts.into_iter().filter(move |(_, account)| {
 | 
				
			||||||
        filters.iter().all(|filter_type| match filter_type {
 | 
					        filters.iter().all(|filter_type| match filter_type {
 | 
				
			||||||
            RpcFilterType::DataSize(size) => account.data.len() as u64 == *size,
 | 
					            RpcFilterType::DataSize(size) => account.data.len() as u64 == *size,
 | 
				
			||||||
            RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data),
 | 
					            RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data),
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    let accounts: Box<dyn Iterator<Item = RpcKeyedAccount>> =
 | 
					    let accounts: Box<dyn Iterator<Item = RpcKeyedAccount>> = if program_id == &spl_token_id_v2_0()
 | 
				
			||||||
        if encoding == UiAccountEncoding::JsonParsed {
 | 
					        && encoding == UiAccountEncoding::JsonParsed
 | 
				
			||||||
            let bank = bank.unwrap(); // If !accounts.is_empty(), bank must be Some
 | 
					        && !accounts_is_empty
 | 
				
			||||||
            Box::new(get_parsed_token_accounts(bank, keyed_accounts))
 | 
					    {
 | 
				
			||||||
        } else {
 | 
					        let bank = bank.unwrap(); // If !accounts_is_empty, bank must be Some
 | 
				
			||||||
            Box::new(
 | 
					        Box::new(get_parsed_token_accounts(bank, keyed_accounts))
 | 
				
			||||||
                keyed_accounts.map(move |(pubkey, account)| RpcKeyedAccount {
 | 
					    } else {
 | 
				
			||||||
                    pubkey: pubkey.to_string(),
 | 
					        Box::new(
 | 
				
			||||||
                    account: UiAccount::encode(&pubkey, account, encoding.clone(), None, None),
 | 
					            keyed_accounts.map(move |(pubkey, account)| RpcKeyedAccount {
 | 
				
			||||||
                }),
 | 
					                pubkey: pubkey.to_string(),
 | 
				
			||||||
            )
 | 
					                account: UiAccount::encode(&pubkey, account, encoding.clone(), None, None),
 | 
				
			||||||
        };
 | 
					            }),
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
    (accounts, last_notified_slot)
 | 
					    (accounts, last_notified_slot)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user