Skip to content

Commit

Permalink
chore: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Nov 14, 2023
1 parent 5a51547 commit 87b0445
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/agent/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub fn build_dashboard_data(
let price_global_metadata =
global_metadata.price_accounts_metadata.remove(&price_key);

let price_identifier = Identifier::new(price_key.clone().to_bytes());
let price_identifier = Identifier::new(price_key.to_bytes());
let price_local_data = local_data.remove(&price_identifier);

prices.insert(
Expand Down Expand Up @@ -308,5 +308,5 @@ pub fn build_dashboard_data(
"remaining_price_ids" => format!("{:?}", remaining_prices));
}

return ret;
ret
}
4 changes: 2 additions & 2 deletions src/agent/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl ProductGlobalMetrics {
}

pub fn update(&self, product_key: &Pubkey, maybe_symbol: Option<String>) {
let symbol_string = maybe_symbol.unwrap_or(format!("unknown_{}", product_key.to_string()));
let symbol_string = maybe_symbol.unwrap_or(format!("unknown_{}", product_key));

#[deny(unused_variables)]
let Self { update_count } = self;
Expand Down Expand Up @@ -413,7 +413,7 @@ impl PriceLocalMetrics {
update_count,
} = self;

let price_key = Pubkey::new(price_id.to_bytes().as_slice());
let price_key = Pubkey::from(price_id.to_bytes());

price
.get_or_create(&PriceLocalLabels {
Expand Down
22 changes: 13 additions & 9 deletions src/agent/pythd/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ impl Adapter {
let subscription_id = self
.handle_subscribe_price_sched(&account.parse()?, notify_price_sched_tx)
.await;
let res = self.send(result_tx, Ok(subscription_id));
res
self.send(result_tx, Ok(subscription_id))
}
Message::UpdatePrice {
account,
Expand Down Expand Up @@ -618,7 +617,10 @@ mod tests {
PublisherAccount,
},
},
solana,
solana::{
self,
network::Network,
},
store::{
global,
global::AllAccountsData,
Expand Down Expand Up @@ -1559,9 +1561,10 @@ mod tests {

// Return the account data to the adapter, from the global store
match test_adapter.global_store_lookup_rx.recv().await.unwrap() {
global::Lookup::LookupAllAccountsData { result_tx } => {
result_tx.send(Ok(get_all_accounts_data())).unwrap()
}
global::Lookup::LookupAllAccountsData {
network: Network::Primary,
result_tx,
} => result_tx.send(Ok(get_all_accounts_data())).unwrap(),
_ => panic!("Uexpected message received from adapter"),
};

Expand Down Expand Up @@ -1784,9 +1787,10 @@ mod tests {

// Return the account data to the adapter, from the global store
match test_adapter.global_store_lookup_rx.recv().await.unwrap() {
global::Lookup::LookupAllAccountsData { result_tx } => {
result_tx.send(Ok(get_all_accounts_data())).unwrap()
}
global::Lookup::LookupAllAccountsData {
network: Network::Primary,
result_tx,
} => result_tx.send(Ok(get_all_accounts_data())).unwrap(),
_ => panic!("Uexpected message received from adapter"),
};

Expand Down
4 changes: 2 additions & 2 deletions src/agent/remote_keypair_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl RemoteKeypairLoader {
config: Config,
logger: Logger,
) -> Vec<JoinHandle<()>> {
let bind_address = config.bind_address.clone();
let bind_address = config.bind_address;

let ip = bind_address.ip();

Expand Down Expand Up @@ -181,7 +181,7 @@ impl RemoteKeypairLoader {
);

// WARNING: All jobs spawned here must report their join handles in this vec
return vec![request_handler_jh, http_api_jh];
vec![request_handler_jh, http_api_jh]
}

/// Validate and apply a keypair to the specified mut reference,
Expand Down
16 changes: 7 additions & 9 deletions src/agent/solana/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ use {
solana_client::{
nonblocking::rpc_client::RpcClient,
rpc_config::RpcSendTransactionConfig,
rpc_response::RpcPrioritizationFee,
},
solana_sdk::{
bs58,
commitment_config::CommitmentConfig,
compute_budget::ComputeBudgetInstruction,
hash::Hash,
Expand Down Expand Up @@ -334,7 +332,7 @@ impl Exporter {
let permissioned_updates = self.get_permissioned_updates().await?;
let price_accounts = permissioned_updates
.iter()
.map(|(identifier, _)| Pubkey::new(&identifier.to_bytes()))
.map(|(identifier, _)| Pubkey::from(identifier.to_bytes()))
.collect::<Vec<_>>();
self.recent_compute_unit_price_micro_lamports = self
.estimate_compute_unit_price_micro_lamports(&price_accounts)
Expand Down Expand Up @@ -470,7 +468,7 @@ impl Exporter {
Ok(fresh_updates
.into_iter()
.filter(|(id, _data)| {
let key_from_id = Pubkey::new((*id).clone().to_bytes().as_slice());
let key_from_id = Pubkey::from((*id).clone().to_bytes());
if self.our_prices.contains(&key_from_id) {
true
} else {
Expand Down Expand Up @@ -628,7 +626,7 @@ impl Exporter {
});
let price_accounts = refreshed_batch
.clone()
.map(|(identifier, _)| Pubkey::new(&identifier.to_bytes()))
.map(|(identifier, _)| Pubkey::from(identifier.to_bytes()))
.collect::<Vec<_>>();

let network_state = *self.network_state_rx.borrow();
Expand All @@ -645,16 +643,16 @@ impl Exporter {
{
self.create_instruction_with_accumulator(
publish_keypair.pubkey(),
Pubkey::new(&identifier.to_bytes()),
&price_info,
Pubkey::from(identifier.to_bytes()),
price_info,
network_state.current_slot,
accumulator_program_key,
)?
} else {
self.create_instruction_without_accumulator(
publish_keypair.pubkey(),
Pubkey::new(&identifier.to_bytes()),
&price_info,
Pubkey::from(identifier.to_bytes()),
price_info,
network_state.current_slot,
)?
};
Expand Down
14 changes: 7 additions & 7 deletions src/agent/solana/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn spawn_oracle(
wss_url.to_string(),
rpc_timeout,
config.commitment,
key_store.program_key.clone(),
key_store.program_key,
updates_tx,
logger.clone(),
);
Expand Down Expand Up @@ -322,7 +322,7 @@ impl Oracle {
) -> Result<()> {
self.global_store_tx
.send(global::Update::ProductAccountUpdate {
account_key: account_key.clone(),
account_key: *account_key,
account: account.clone(),
})
.await
Expand All @@ -336,8 +336,8 @@ impl Oracle {
) -> Result<()> {
self.global_store_tx
.send(global::Update::PriceAccountUpdate {
account_key: account_key.clone(),
account: account.clone(),
account_key: *account_key,
account: *account,
})
.await
.map_err(|_| anyhow!("failed to notify price account update"))
Expand Down Expand Up @@ -437,7 +437,7 @@ impl Poller {
.entry(component.publisher)
.or_insert(HashSet::new());

component_pub_entry.insert(price_key.clone());
component_pub_entry.insert(*price_key);
}
}

Expand Down Expand Up @@ -488,7 +488,7 @@ impl Poller {
.iter()
.filter(|pubkey| **pubkey != Pubkey::default())
{
product_keys.push(account_key.clone());
product_keys.push(*account_key);
}
}

Expand Down Expand Up @@ -578,7 +578,7 @@ impl Poller {
}

if price.next != Pubkey::default() {
next_todo.push(price.next.clone());
next_todo.push(price.next);
}
} else {
warn!(self.logger, "Could not look up price account on chain, skipping"; "price_key" => price_key.to_string(),);
Expand Down
2 changes: 1 addition & 1 deletion src/bin/agent_migrate_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub fn main() -> Result<()> {
eprintln!("Migration OK. Result:");
std::io::stderr().flush()?;

println!("{}", doc.to_string());
println!("{}", doc);

Ok(())
}
Expand Down

0 comments on commit 87b0445

Please sign in to comment.