Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiezzel committed May 16, 2024
1 parent d194ca9 commit fe138f9
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

16 changes: 10 additions & 6 deletions src/gateway_allocations/compute_units_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ impl ComputeUnitsStorage {
self.operator_by_gateway_id.drain();

for cluster in clusters {
self.operators.insert(cluster.operator_addr, Operator {
allocated_cus: cluster.allocated_computation_units,
spent_cus: 0.into(),
});
self.operators.insert(
cluster.operator_addr,
Operator {
allocated_cus: cluster.allocated_computation_units,
spent_cus: 0.into(),
},
);
for gateway in cluster.gateway_ids {
self.operator_by_gateway_id.insert(gateway, cluster.operator_addr);
self.operator_by_gateway_id
.insert(gateway, cluster.operator_addr);
}
}
}
Expand All @@ -50,4 +54,4 @@ impl ComputeUnitsStorage {
Status::NotEnoughCU
}
}
}
}
2 changes: 1 addition & 1 deletion src/gateway_allocations/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod allocations_checker;
pub mod compute_units_storage;
pub use compute_units_storage::Status;
pub use compute_units_storage::Status;
8 changes: 4 additions & 4 deletions src/query/eth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copied from https://github.com/subsquid/firehose-grpc/blob/80bc1da04e4197df6fdf632937dec372794ddea0/src/archive.rs

use serde::{Deserialize, Serialize};
use serde_json::{Number, map::Map as JsonMap};
use serde_json::{map::Map as JsonMap, Number};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all(deserialize = "camelCase"))]
Expand Down Expand Up @@ -51,7 +51,7 @@ pub struct LogRequest {
#[serde(skip_serializing_if = "std::ops::Not::not", default)]
pub transaction: bool,
#[serde(skip_serializing_if = "std::ops::Not::not", default)]
pub transaction_traces: bool
pub transaction_traces: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -295,12 +295,12 @@ fn parse_selection<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
where
D: serde::Deserializer<'de>,
{
let map =JsonMap::deserialize(deserializer)?;
let map = JsonMap::deserialize(deserializer)?;
let mut result = Vec::new();
for (key, value) in map {
if value.as_bool() == Some(true) {
result.push(key);
}
}
Ok(result)
}
}
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod state;
pub mod dataset;
pub mod state;
2 changes: 1 addition & 1 deletion src/types/state.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::dataset::Dataset;
use crate::storage::layout::DataChunk;
use itertools::Itertools;
use std::{
collections::{BTreeSet, HashMap},
sync::Arc,
};
use itertools::Itertools;
use subsquid_messages::{Range, RangeSet};

pub type ChunkSet = BTreeSet<ChunkRef>;
Expand Down
2 changes: 1 addition & 1 deletion src/util/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use itertools::{EitherOrBoth, Itertools};
pub trait WithLookahead: Iterator {
fn lookahead(self) -> impl Iterator<Item = (Self::Item, Option<Self::Item>)>
where
Self: Clone
Self: Clone,
{
self.clone().zip_longest(self.skip(1)).map(|x| match x {
EitherOrBoth::Both(cur, next) => (cur, Some(next)),
Expand Down
9 changes: 4 additions & 5 deletions src/util/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ use std::sync::Mutex;
use anyhow::{anyhow, Result};

pub struct UseOnce<T> {
inner: Mutex<Option<T>>
inner: Mutex<Option<T>>,
}

impl<T> UseOnce<T> {
pub fn new(value: T) -> Self {
UseOnce {
inner: Mutex::new(Some(value))
inner: Mutex::new(Some(value)),
}
}

pub fn take(&self) -> Result<T> {
self
.inner
self.inner
.try_lock()
.ok()
.and_then(|mut opt| opt.take())
.ok_or_else(|| anyhow!("Attempted to take value twice"))
}
}
}
2 changes: 1 addition & 1 deletion src/util/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use tracing_subscriber::EnvFilter;
use camino::Utf8PathBuf as PathBuf;
use tracing_subscriber::EnvFilter;

pub fn tests_data() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/data")
Expand Down

0 comments on commit fe138f9

Please sign in to comment.