Skip to content

Commit

Permalink
feat: verify that price feed index is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Riateche committed Aug 7, 2024
1 parent 0387cdf commit 491e168
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pyth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check Pythnet
on:
pull_request:
push:
branches: [main]
branches: [pyth-v1.14.17]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions runtime/src/bank/pyth_batch_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,22 @@ pub fn apply_published_prices(
new_prices: &HashMap<u32, Vec<PublisherPriceValue>>,
slot: Slot,
) -> bool {
let price_feed_index = price_data.feed_index as u32;
if price_data.feed_index == 0 {
return false;
}
let mut any_update = false;
for new_price in new_prices.get(&price_feed_index).unwrap_or(&Vec::new()) {
for new_price in new_prices
.get(&price_data.feed_index)
.unwrap_or(&Vec::new())
{
match apply_published_price(price_data, new_price, slot) {
Ok(()) => {
any_update = true;
}
Err(err) => {
warn!(
"failed to apply publisher price to price feed {}: {}",
price_data.feed_index as u32, err
price_data.feed_index, err
);
}
}
Expand Down Expand Up @@ -286,7 +291,7 @@ fn apply_published_price(
.ok_or(ApplyPublishedPriceError::InvalidPublishersNum)?;

let publisher_index = find_publisher_index(publishers, &new_price.publisher).ok_or(
ApplyPublishedPriceError::NoPermission(price_data.feed_index as u32, new_price.publisher),
ApplyPublishedPriceError::NoPermission(price_data.feed_index, new_price.publisher),
)?;

// IMPORTANT: If the publisher does not meet the price/conf
Expand Down

0 comments on commit 491e168

Please sign in to comment.