Skip to content

Commit 6eb78b8

Browse files
authored
[fix] Fix timestamp to handle negative values (#139)
1 parent bef75a4 commit 6eb78b8

File tree

19 files changed

+76
-66
lines changed

19 files changed

+76
-66
lines changed

aptos-indexer-processors-sdk/instrumented-channel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,6 @@ mod tests {
188188
assert_eq!(receiver.recv().await.unwrap(), 42);
189189
// TODO: check prometheus metrics
190190
let metrics = gather_metrics_to_string();
191-
println!("{}", metrics);
191+
println!("{metrics}");
192192
}
193193
}

aptos-indexer-processors-sdk/moving-average/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ mod test {
7979
}
8080
// No matter what algorithm we use, the average should be 99 at least.
8181
let avg = ma.avg();
82-
assert!(avg >= 99.0, "Average is too low: {}", avg);
82+
assert!(avg >= 99.0, "Average is too low: {avg}");
8383
}
8484
}

aptos-indexer-processors-sdk/sample/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ mod tests {
166166
);
167167

168168
sample!(SampleRate::Frequency(2), {
169-
println!("hello {}", i);
169+
println!("hello {i}");
170170
});
171171

172-
sample!(SampleRate::Frequency(2), println!("hello {}", i));
172+
sample!(SampleRate::Frequency(2), println!("hello {i}"));
173173

174174
sample! {
175175
SampleRate::Frequency(2),
176176

177177
for j in 10..20 {
178-
println!("hello {}", j);
178+
println!("hello {j}");
179179
}
180180
}
181181
}

aptos-indexer-processors-sdk/sdk/src/builder/processor_builder.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl GraphBuilder {
127127
if let Some(node) = node_map.get_mut(&node_index) {
128128
node.join_handle = Some(join_handle);
129129
} else {
130-
panic!("Node with index {} not found in node_map", node_index);
130+
panic!("Node with index {node_index} not found in node_map");
131131
}
132132
}
133133

@@ -178,7 +178,7 @@ impl GraphBuilder {
178178
&edge_attribute_getter,
179179
&node_attribute_getter,
180180
);
181-
format!("{}", dot)
181+
format!("{dot}")
182182
}
183183
}
184184

@@ -278,7 +278,7 @@ where
278278
sender.send(input.clone()).await.unwrap();
279279
},
280280
Err(e) => {
281-
panic!("Error receiving from previous step for fanout: {:?}", e);
281+
panic!("Error receiving from previous step for fanout: {e:?}");
282282
},
283283
}
284284
}
@@ -359,10 +359,8 @@ where
359359
let mut output_senders = Vec::new();
360360
let mut output_receivers = Vec::new();
361361
for idx in 0..num_outputs {
362-
let (output_sender, output_receiver) = instrumented_bounded_channel(
363-
&format!("{}::Fanout::{}", previous_step_name, idx),
364-
0,
365-
);
362+
let (output_sender, output_receiver) =
363+
instrumented_bounded_channel(&format!("{previous_step_name}::Fanout::{idx}"), 0);
366364
output_senders.push(output_sender);
367365
output_receivers.push(output_receiver);
368366
}
@@ -389,7 +387,7 @@ where
389387
}
390388
},
391389
Err(e) => {
392-
panic!("Error receiving from previous step for fanout: {:?}", e);
390+
panic!("Error receiving from previous step for fanout: {e:?}");
393391
},
394392
}
395393
}

aptos-indexer-processors-sdk/sdk/src/common_steps/transaction_stream_step.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where
3636
TransactionStreamInternal::new(transaction_stream_config.clone()).await;
3737
match transaction_stream_res {
3838
Err(e) => Err(ProcessorError::StepInitError {
39-
message: format!("Error creating transaction stream: {:?}", e),
39+
message: format!("Error creating transaction stream: {e:?}"),
4040
}),
4141
Ok(transaction_stream) => Ok(Self {
4242
transaction_stream: Mutex::new(transaction_stream),
@@ -131,7 +131,7 @@ where
131131
" Error reconnecting transaction stream."
132132
);
133133
Err(ProcessorError::PollError {
134-
message: format!("Error reconnecting to TransactionStream: {:?}", e),
134+
message: format!("Error reconnecting to TransactionStream: {e:?}"),
135135
})
136136
},
137137
}

aptos-indexer-processors-sdk/sdk/src/common_steps/write_rate_limit_step.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,12 @@ mod tests {
298298

299299
assert!(
300300
time_diff >= Duration::from_millis(500),
301-
"Expected at least 500ms delay between processing, got {:?}",
302-
time_diff
301+
"Expected at least 500ms delay between processing, got {time_diff:?}",
303302
);
304303

305304
assert!(
306305
time_diff <= Duration::from_millis(700),
307-
"Expected less than 700ms delay between processing, got {:?}",
308-
time_diff
306+
"Expected less than 700ms delay between processing, got {time_diff:?}",
309307
);
310308

311309
// Ensure the outputs are as expected.

aptos-indexer-processors-sdk/sdk/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mod tests {
144144

145145
let graph = second_builder.graph;
146146
let dot = graph.dot();
147-
println!("{:}", dot);
147+
println!("{dot:}");
148148
//first_handle.abort();
149149
//second_handle.abort();
150150
}
@@ -226,7 +226,7 @@ mod tests {
226226

227227
let graph = fanout_builder.graph;
228228
let dot = graph.dot();
229-
println!("{:}", dot);
229+
println!("{dot:}");
230230
//first_handle.abort();
231231
//second_handle.abort();
232232
}

aptos-indexer-processors-sdk/sdk/src/postgres/basic_processor/basic_processor_step.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ where
3535
(self.process_function)(transactions.data, self.conn_pool.clone())
3636
.await
3737
.map_err(|e| ProcessorError::ProcessError {
38-
message: format!("Processing transactionsfailed: {:?}", e),
38+
message: format!("Processing transactionsfailed: {e:?}"),
3939
})?;
4040
Ok(Some(TransactionContext {
4141
data: (), // Stub out data since it's not used in the next step

aptos-indexer-processors-sdk/sdk/src/postgres/utils/database.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn establish_connection(database_url: &str) -> BoxFuture<ConnectionResult<AsyncP
6565
.expect("Could not connect to database");
6666
tokio::spawn(async move {
6767
if let Err(e) = connection.await {
68-
eprintln!("connection error: {}", e);
68+
eprintln!("connection error: {e}");
6969
}
7070
});
7171
AsyncPgConnection::try_from(client).await
@@ -82,7 +82,7 @@ fn parse_and_clean_db_url(url: &str) -> (String, Option<String>) {
8282
if k == "sslrootcert" {
8383
cert_path = Some(v.parse().unwrap());
8484
} else {
85-
query.push_str(&format!("{}={}&", k, v));
85+
query.push_str(&format!("{k}={v}&"));
8686
}
8787
});
8888
db_url.set_query(Some(&query));
@@ -165,7 +165,7 @@ where
165165
let conn = &mut pool.get().await.map_err(|e| {
166166
warn!("Error getting connection from pool: {:?}", e);
167167
ProcessorError::DBStoreError {
168-
message: format!("{:#}", e),
168+
message: format!("{e:#}"),
169169
query: Some(debug_string.clone()),
170170
}
171171
})?;
@@ -176,7 +176,7 @@ where
176176
warn!("Error running query: {:?}\n{:?}", e, debug_string);
177177
})
178178
.map_err(|e| ProcessorError::DBStoreError {
179-
message: format!("{:#}", e),
179+
message: format!("{e:#}"),
180180
query: Some(debug_string),
181181
})
182182
}

aptos-indexer-processors-sdk/sdk/src/server_framework.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ pub trait RunnableConfig: DeserializeOwned + Send + Sync + 'static {
107107
/// Parse a yaml file into a struct.
108108
pub fn load<T: for<'de> Deserialize<'de>>(path: &PathBuf) -> Result<T> {
109109
let mut file =
110-
File::open(path).with_context(|| format!("failed to open the file at path: {:?}", path))?;
110+
File::open(path).with_context(|| format!("failed to open the file at path: {path:?}",))?;
111111
let mut contents = String::new();
112112
file.read_to_string(&mut contents)
113-
.with_context(|| format!("failed to read the file at path: {:?}", path))?;
113+
.with_context(|| format!("failed to read the file at path: {path:?}",))?;
114114
serde_yaml::from_str::<T>(&contents).context("Unable to parse yaml file")
115115
}
116116

@@ -138,14 +138,14 @@ pub fn setup_panic_handler() {
138138
#[allow(deprecated)]
139139
fn handle_panic(panic_info: &PanicInfo<'_>) {
140140
// The Display formatter for a PanicInfo contains the message, payload and location.
141-
let details = format!("{}", panic_info);
141+
let details = format!("{panic_info}",);
142142
let backtrace = format!("{:#?}", Backtrace::new());
143143
let info = CrashInfo { details, backtrace };
144144
let crash_info = toml::to_string_pretty(&info).unwrap();
145145
error!("{}", crash_info);
146146
// TODO / HACK ALARM: Write crash info synchronously via eprintln! to ensure it is written before the process exits which error! doesn't guarantee.
147147
// This is a workaround until https://github.com/aptos-labs/aptos-core/issues/2038 is resolved.
148-
eprintln!("{}", crash_info);
148+
eprintln!("{crash_info}",);
149149
// Kill the process
150150
process::exit(12);
151151
}
@@ -190,7 +190,7 @@ pub async fn register_probes_and_metrics_handler(
190190
#[cfg(target_os = "linux")]
191191
let router = router.merge(Router::new().route("/profilez", get(profilez_handler)));
192192

193-
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port))
193+
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{port}",))
194194
.await
195195
.expect("Failed to bind TCP listener");
196196
axum::serve(listener, router).await.unwrap();
@@ -204,7 +204,7 @@ async fn metrics_handler() -> impl IntoResponse {
204204
prometheus_client_rust_metrics,
205205
)
206206
.into_response(),
207-
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, format!("{:?}", err)).into_response(),
207+
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, format!("{err:?}",)).into_response(),
208208
}
209209
}
210210

@@ -267,7 +267,7 @@ mod tests {
267267
test: 123
268268
test_name: "test"
269269
"#;
270-
writeln!(file, "{}", raw_yaml_content).expect("write_all failure");
270+
writeln!(file, "{raw_yaml_content}").expect("write_all failure");
271271

272272
let config = load::<GenericConfig<TestConfig>>(&file_path).unwrap();
273273
assert_eq!(config.health_check_port, 12345);

0 commit comments

Comments
 (0)