Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SupernaviX committed Dec 4, 2024
1 parent 3042470 commit 71aae92
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/raft/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl RaftState {
leader.clone_from(current_leader);
}
};
if !old_voted_for.is_some_and(|id| id == from) {
if old_voted_for.is_none_or(|id| id != from) {
// If we're newly voting for someone, reset the election timeout
self.last_event = timestamp;
}
Expand Down Expand Up @@ -302,11 +302,10 @@ impl RaftState {
);
self.set_status(RaftStatus::Leader { abdicating: false });
// Immediately send a heartbeat to make leader election stable
return self
.peers
self.peers
.iter()
.map(|peer| (peer.clone(), RaftMessage::Heartbeat { term: *term }))
.collect();
.collect()
} else {
vec![]
}
Expand Down
2 changes: 1 addition & 1 deletion src/signature_aggregator/price_instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl PriceInstrumentation {
}

pub fn track_prices(&mut self, round: &str, prices: &[PriceFeed]) {
if !self.round.as_ref().is_some_and(|r| r == round) {
if self.round.as_ref().is_none_or(|r| r != round) {
return;
}
for (key, value) in prices.iter().flat_map(extract_prices_from_feed) {
Expand Down
4 changes: 2 additions & 2 deletions src/signature_aggregator/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,10 @@ impl Signer {
.await
.context("Could not publish signed result")?;

if !self
if self
.latest_payload
.as_ref()
.is_some_and(|old| old.timestamp > payload.timestamp)
.is_none_or(|old| old.timestamp <= payload.timestamp)
{
self.latest_payload = Some(payload);
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/binance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Source for BinanceSource {
self.streams.values().map(|c| c.token.clone()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/sources/bybit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use anyhow::{anyhow, Result};
use dashmap::DashMap;
use futures::{FutureExt, SinkExt, StreamExt};
use futures::{future::BoxFuture, FutureExt, SinkExt, StreamExt};
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
use tokio::{
Expand Down Expand Up @@ -51,10 +51,7 @@ impl Source for ByBitSource {
.collect()
}

fn query<'a>(
&'a self,
sink: &'a PriceSink,
) -> futures::prelude::future::BoxFuture<anyhow::Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Source for CoinbaseSource {
self.products.values().map(|p| p.token.clone()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/fxratesapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Source for FxRatesApiSource {
fn tokens(&self) -> Vec<String> {
self.currencies.clone()
}
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/maestro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Source for MaestroSource {
self.tokens.iter().map(|t| t.token.to_string()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/minswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Source for MinswapSource {
self.pools.iter().map(|p| p.pool.token.clone()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ pub trait Source {
Duration::from_secs(30)
}
fn tokens(&self) -> Vec<String>;
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>>;
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>>;
}
2 changes: 1 addition & 1 deletion src/sources/spectrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Source for SpectrumSource {
self.pools.iter().map(|p| p.pool.token.clone()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/sundaeswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Source for SundaeSwapSource {
self.pools.iter().map(|p| p.token.clone()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<anyhow::Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/sundaeswap_kupo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Source for SundaeSwapKupoSource {
self.pools.iter().map(|e| e.pool.token.clone()).collect()
}

fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<Result<()>> {
fn query<'a>(&'a self, sink: &'a PriceSink) -> BoxFuture<'a, Result<()>> {
self.query_impl(sink).boxed()
}
}
Expand Down

0 comments on commit 71aae92

Please sign in to comment.