Skip to content

Commit cbf0b21

Browse files
committed
style: use fully qualified name for anyhow results
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent 4a594c9 commit cbf0b21

File tree

8 files changed

+40
-41
lines changed

8 files changed

+40
-41
lines changed

crates/monitor/src/escrow_accounts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
};
99

1010
use alloy::primitives::{Address, U256};
11-
use anyhow::{anyhow, Result};
11+
use anyhow::anyhow;
1212
use indexer_query::escrow_account::{self, EscrowAccountQuery};
1313
use thiserror::Error;
1414
use tokio::sync::watch::Receiver;
@@ -104,7 +104,7 @@ async fn get_escrow_accounts(
104104
escrow_subgraph: &'static SubgraphClient,
105105
indexer_address: Address,
106106
reject_thawing_signers: bool,
107-
) -> Result<EscrowAccounts> {
107+
) -> anyhow::Result<EscrowAccounts> {
108108
// thawEndTimestamp == 0 means that the signer is not thawing. This also means
109109
// that we don't wait for the thawing period to end before stopping serving
110110
// queries for this signer.

crates/tap-agent/src/agent/sender_account.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use alloy::{
1212
primitives::{Address, U256},
1313
sol_types::Eip712Domain,
1414
};
15-
use anyhow::Result;
1615
use bigdecimal::{num_bigint::ToBigInt, ToPrimitive};
1716
use futures::{stream, StreamExt};
1817
use indexer_monitor::{EscrowAccounts, SubgraphClient};
@@ -215,7 +214,7 @@ impl State {
215214
&self,
216215
sender_account_ref: ActorRef<SenderAccountMessage>,
217216
allocation_id: Address,
218-
) -> Result<()> {
217+
) -> anyhow::Result<()> {
219218
tracing::trace!(
220219
%self.sender,
221220
%allocation_id,
@@ -252,7 +251,7 @@ impl State {
252251
sender_allocation_id
253252
}
254253

255-
async fn rav_request_for_heaviest_allocation(&mut self) -> Result<()> {
254+
async fn rav_request_for_heaviest_allocation(&mut self) -> anyhow::Result<()> {
256255
let allocation_id = self
257256
.sender_fee_tracker
258257
.get_heaviest_allocation_id()
@@ -272,7 +271,7 @@ impl State {
272271
self.rav_request_for_allocation(allocation_id).await
273272
}
274273

275-
async fn rav_request_for_allocation(&mut self, allocation_id: Address) -> Result<()> {
274+
async fn rav_request_for_allocation(&mut self, allocation_id: Address) -> anyhow::Result<()> {
276275
let sender_allocation_id = self.format_sender_allocation(&allocation_id);
277276
let allocation = ActorRef::<SenderAllocationMessage>::where_is(sender_allocation_id);
278277

@@ -482,7 +481,7 @@ impl Actor for SenderAccount {
482481
prefix,
483482
retry_interval,
484483
}: Self::Arguments,
485-
) -> std::result::Result<Self::State, ActorProcessingErr> {
484+
) -> Result<Self::State, ActorProcessingErr> {
486485
let myself_clone = myself.clone();
487486
let _indexer_allocations_handle = watch_pipe(indexer_allocations, move |allocation_ids| {
488487
let allocation_ids = allocation_ids.clone();
@@ -651,7 +650,7 @@ impl Actor for SenderAccount {
651650
myself: ActorRef<Self::Msg>,
652651
message: Self::Msg,
653652
state: &mut Self::State,
654-
) -> std::result::Result<(), ActorProcessingErr> {
653+
) -> Result<(), ActorProcessingErr> {
655654
tracing::span!(
656655
Level::TRACE,
657656
"SenderAccount handle()",
@@ -937,7 +936,7 @@ impl Actor for SenderAccount {
937936
myself: ActorRef<Self::Msg>,
938937
message: SupervisionEvent,
939938
state: &mut Self::State,
940-
) -> std::result::Result<(), ActorProcessingErr> {
939+
) -> Result<(), ActorProcessingErr> {
941940
tracing::trace!(
942941
sender = %state.sender,
943942
message = ?message,
@@ -1019,7 +1018,7 @@ impl Actor for SenderAccount {
10191018
}
10201019

10211020
impl SenderAccount {
1022-
pub async fn deny_sender(pool: &sqlx::PgPool, sender: Address) {
1021+
pub async fn deny_sender(pool: &PgPool, sender: Address) {
10231022
sqlx::query!(
10241023
r#"
10251024
INSERT INTO scalar_tap_denylist (sender_address)

crates/tap-agent/src/agent/sender_accounts_manager.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
};
99

1010
use alloy::{primitives::Address, sol_types::Eip712Domain};
11-
use anyhow::{anyhow, bail, Result};
11+
use anyhow::{anyhow, bail};
1212
use futures::{stream, StreamExt};
1313
use indexer_allocation::Allocation;
1414
use indexer_monitor::{EscrowAccounts, SubgraphClient};
@@ -105,7 +105,7 @@ impl Actor for SenderAccountsManager {
105105
sender_aggregator_endpoints,
106106
prefix,
107107
}: Self::Arguments,
108-
) -> std::result::Result<Self::State, ActorProcessingErr> {
108+
) -> Result<Self::State, ActorProcessingErr> {
109109
let (allocations_tx, allocations_rx) = watch::channel(HashSet::<Address>::new());
110110
watch_pipe(indexer_allocations.clone(), move |allocation_id| {
111111
let allocation_set = allocation_id.keys().cloned().collect::<HashSet<Address>>();
@@ -175,7 +175,7 @@ impl Actor for SenderAccountsManager {
175175
&self,
176176
_: ActorRef<Self::Msg>,
177177
state: &mut Self::State,
178-
) -> std::result::Result<(), ActorProcessingErr> {
178+
) -> Result<(), ActorProcessingErr> {
179179
// Abort the notification watcher on drop. Otherwise it may panic because the PgPool could
180180
// get dropped before. (Observed in tests)
181181
if let Some(handle) = &state.new_receipts_watcher_handle {
@@ -189,7 +189,7 @@ impl Actor for SenderAccountsManager {
189189
myself: ActorRef<Self::Msg>,
190190
msg: Self::Msg,
191191
state: &mut Self::State,
192-
) -> std::result::Result<(), ActorProcessingErr> {
192+
) -> Result<(), ActorProcessingErr> {
193193
tracing::trace!(
194194
message = ?msg,
195195
"New SenderAccountManager message"
@@ -226,7 +226,7 @@ impl Actor for SenderAccountsManager {
226226
myself: ActorRef<Self::Msg>,
227227
message: SupervisionEvent,
228228
state: &mut Self::State,
229-
) -> std::result::Result<(), ActorProcessingErr> {
229+
) -> Result<(), ActorProcessingErr> {
230230
match message {
231231
SupervisionEvent::ActorTerminated(cell, _, reason) => {
232232
let sender_id = cell.get_name();
@@ -440,7 +440,7 @@ impl State {
440440
&self,
441441
sender_id: &Address,
442442
allocation_ids: HashSet<Address>,
443-
) -> Result<SenderAccountArgs> {
443+
) -> anyhow::Result<SenderAccountArgs> {
444444
Ok(SenderAccountArgs {
445445
config: self.config,
446446
pgpool: self.pgpool.clone(),
@@ -519,7 +519,7 @@ async fn handle_notification(
519519
new_receipt_notification: NewReceiptNotification,
520520
escrow_accounts_rx: Receiver<EscrowAccounts>,
521521
prefix: Option<&str>,
522-
) -> Result<()> {
522+
) -> anyhow::Result<()> {
523523
tracing::trace!(
524524
notification = ?new_receipt_notification,
525525
"New receipt notification detected!"

crates/tap-agent/src/agent/sender_allocation.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
};
88

99
use alloy::{hex::ToHexExt, primitives::Address, sol_types::Eip712Domain};
10-
use anyhow::{anyhow, ensure, Result};
10+
use anyhow::{anyhow, ensure};
1111
use bigdecimal::{num_bigint::BigInt, ToPrimitive};
1212
use indexer_monitor::{EscrowAccounts, SubgraphClient};
1313
use jsonrpsee::{core::client::ClientT, rpc_params};
@@ -165,7 +165,7 @@ impl Actor for SenderAllocation {
165165
&self,
166166
_myself: ActorRef<Self::Msg>,
167167
args: Self::Arguments,
168-
) -> std::result::Result<Self::State, ActorProcessingErr> {
168+
) -> Result<Self::State, ActorProcessingErr> {
169169
let sender_account_ref = args.sender_account_ref.clone();
170170
let allocation_id = args.allocation_id;
171171
let mut state = SenderAllocationState::new(args).await?;
@@ -207,7 +207,7 @@ impl Actor for SenderAllocation {
207207
&self,
208208
_myself: ActorRef<Self::Msg>,
209209
state: &mut Self::State,
210-
) -> std::result::Result<(), ActorProcessingErr> {
210+
) -> Result<(), ActorProcessingErr> {
211211
tracing::info!(
212212
sender = %state.sender,
213213
allocation_id = %state.allocation_id,
@@ -258,7 +258,7 @@ impl Actor for SenderAllocation {
258258
_myself: ActorRef<Self::Msg>,
259259
message: Self::Msg,
260260
state: &mut Self::State,
261-
) -> std::result::Result<(), ActorProcessingErr> {
261+
) -> Result<(), ActorProcessingErr> {
262262
tracing::trace!(
263263
sender = %state.sender,
264264
allocation_id = %state.allocation_id,
@@ -394,18 +394,21 @@ impl SenderAllocationState {
394394
})
395395
}
396396

397-
async fn recalculate_all_unaggregated_fees(&self) -> Result<UnaggregatedReceipts> {
397+
async fn recalculate_all_unaggregated_fees(&self) -> anyhow::Result<UnaggregatedReceipts> {
398398
self.calculate_fee_until_last_id(i64::MAX).await
399399
}
400400

401-
async fn calculate_unaggregated_fee(&self) -> Result<UnaggregatedReceipts> {
401+
async fn calculate_unaggregated_fee(&self) -> anyhow::Result<UnaggregatedReceipts> {
402402
self.calculate_fee_until_last_id(self.unaggregated_fees.last_id as i64)
403403
.await
404404
}
405405

406406
/// Delete obsolete receipts in the DB w.r.t. the last RAV in DB, then update the tap manager
407407
/// with the latest unaggregated fees from the database.
408-
async fn calculate_fee_until_last_id(&self, last_id: i64) -> Result<UnaggregatedReceipts> {
408+
async fn calculate_fee_until_last_id(
409+
&self,
410+
last_id: i64,
411+
) -> anyhow::Result<UnaggregatedReceipts> {
409412
tracing::trace!("calculate_unaggregated_fee()");
410413
self.tap_manager.remove_obsolete_receipts().await?;
411414

@@ -458,7 +461,7 @@ impl SenderAllocationState {
458461
})
459462
}
460463

461-
async fn calculate_invalid_receipts_fee(&self) -> Result<UnaggregatedReceipts> {
464+
async fn calculate_invalid_receipts_fee(&self) -> anyhow::Result<UnaggregatedReceipts> {
462465
tracing::trace!("calculate_invalid_receipts_fee()");
463466
let signers = signers_trimmed(self.escrow_accounts.clone(), self.sender).await?;
464467

@@ -501,7 +504,7 @@ impl SenderAllocationState {
501504
})
502505
}
503506

504-
async fn request_rav(&mut self) -> Result<()> {
507+
async fn request_rav(&mut self) -> anyhow::Result<()> {
505508
match self.rav_requester_single().await {
506509
Ok(rav) => {
507510
self.unaggregated_fees = self.calculate_unaggregated_fee().await?;
@@ -691,7 +694,7 @@ impl SenderAllocationState {
691694
}
692695
}
693696

694-
pub async fn mark_rav_last(&self) -> Result<()> {
697+
pub async fn mark_rav_last(&self) -> anyhow::Result<()> {
695698
tracing::info!(
696699
sender = %self.sender,
697700
allocation_id = %self.allocation_id,
@@ -731,7 +734,7 @@ impl SenderAllocationState {
731734
async fn store_invalid_receipts(
732735
&mut self,
733736
receipts: &[ReceiptWithState<Failed>],
734-
) -> Result<()> {
737+
) -> anyhow::Result<()> {
735738
let reciepts_len = receipts.len();
736739
let mut reciepts_signers = Vec::with_capacity(reciepts_len);
737740
let mut encoded_signatures = Vec::with_capacity(reciepts_len);
@@ -835,7 +838,7 @@ impl SenderAllocationState {
835838
expected_rav: &ReceiptAggregateVoucher,
836839
rav: &EIP712SignedMessage<ReceiptAggregateVoucher>,
837840
reason: &str,
838-
) -> Result<()> {
841+
) -> anyhow::Result<()> {
839842
sqlx::query!(
840843
r#"
841844
INSERT INTO scalar_tap_rav_requests_failed (

crates/tap-agent/src/cli.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use std::path::PathBuf;
55

6-
use anyhow::Result;
76
use clap::Parser;
87
use indexer_config::{Config as IndexerConfig, ConfigPrefix};
98
use tracing::{
@@ -39,7 +38,7 @@ fn init_tracing(format: String) -> Result<(), SetGlobalDefaultError> {
3938
}
4039
}
4140

42-
pub fn get_config() -> Result<IndexerConfig> {
41+
pub fn get_config() -> anyhow::Result<IndexerConfig> {
4342
let cli = Cli::parse();
4443
let config = IndexerConfig::parse(ConfigPrefix::Tap, cli.config.as_ref()).map_err(|e| {
4544
tracing::error!(

crates/tap-agent/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use anyhow::Result;
54
use indexer_tap_agent::{agent, metrics, CONFIG};
65
use ractor::ActorStatus;
76
use tokio::signal::unix::{signal, SignalKind};
87

98
#[tokio::main]
10-
async fn main() -> Result<()> {
9+
async fn main() -> anyhow::Result<()> {
1110
// Parse basic configurations, also initializes logging.
1211
lazy_static::initialize(&CONFIG);
1312

crates/tap-agent/src/tap/context/receipt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ mod test {
193193
use std::collections::HashMap;
194194

195195
use alloy::{primitives::U256, signers::local::PrivateKeySigner};
196-
use anyhow::Result;
197196
use indexer_monitor::EscrowAccounts;
198197
use lazy_static::lazy_static;
199198
use sqlx::PgPool;
@@ -252,7 +251,7 @@ mod test {
252251
escrow_accounts: Receiver<EscrowAccounts>,
253252
received_receipt_vec: &[ReceiptWithState<Checking>],
254253
range: R,
255-
) -> Result<()> {
254+
) -> anyhow::Result<()> {
256255
let escrow_accounts_snapshot = escrow_accounts.borrow();
257256

258257
// Filtering the received receipts by timestamp range
@@ -302,7 +301,7 @@ mod test {
302301
escrow_accounts: Receiver<EscrowAccounts>,
303302
received_receipt_vec: &[ReceiptWithState<Checking>],
304303
range: R,
305-
) -> Result<()> {
304+
) -> anyhow::Result<()> {
306305
let escrow_accounts_snapshot = escrow_accounts.borrow();
307306

308307
// Storing the receipts

crates/tap-agent/src/test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub mod actors {
289289
&self,
290290
myself: ActorRef<Self::Msg>,
291291
state: &mut Self::State,
292-
) -> std::result::Result<(), ActorProcessingErr> {
292+
) -> Result<(), ActorProcessingErr> {
293293
self.inner.post_stop(myself, state).await
294294
}
295295

@@ -298,7 +298,7 @@ pub mod actors {
298298
myself: ActorRef<Self::Msg>,
299299
msg: Self::Msg,
300300
state: &mut Self::State,
301-
) -> std::result::Result<(), ActorProcessingErr> {
301+
) -> Result<(), ActorProcessingErr> {
302302
let result = self.inner.handle(myself, msg, state).await;
303303
self.notify.notify_one();
304304
result
@@ -309,7 +309,7 @@ pub mod actors {
309309
myself: ActorRef<Self::Msg>,
310310
message: SupervisionEvent,
311311
state: &mut Self::State,
312-
) -> std::result::Result<(), ActorProcessingErr> {
312+
) -> Result<(), ActorProcessingErr> {
313313
self.inner
314314
.handle_supervisor_evt(myself, message, state)
315315
.await
@@ -467,7 +467,7 @@ pub mod actors {
467467
&self,
468468
_myself: ActorRef<Self::Msg>,
469469
_allocation_ids: Self::Arguments,
470-
) -> std::result::Result<Self::State, ActorProcessingErr> {
470+
) -> Result<Self::State, ActorProcessingErr> {
471471
Ok(())
472472
}
473473

@@ -476,7 +476,7 @@ pub mod actors {
476476
_myself: ActorRef<Self::Msg>,
477477
message: Self::Msg,
478478
_state: &mut Self::State,
479-
) -> std::result::Result<(), ActorProcessingErr> {
479+
) -> Result<(), ActorProcessingErr> {
480480
self.last_message_emitted.send(message).await.unwrap();
481481
Ok(())
482482
}

0 commit comments

Comments
 (0)