Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Asseman <[email protected]>
  • Loading branch information
aasseman committed Oct 24, 2023
1 parent b12ddb0 commit 1d8f73e
Show file tree
Hide file tree
Showing 12 changed files with 522 additions and 183 deletions.

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

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

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

This file was deleted.

1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions tap_agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ faux = "0.1.10"
indexer-common = { path = "../common", features = ["mock"] }
rstest = "0.18.1"
tempfile = "3.8.0"
wiremock = "0.5.19"
2 changes: 1 addition & 1 deletion tap_agent/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct Cli {
env = "CONFIG",
help = "Indexer service configuration file (YAML format)"
)]
config: Option<String>,
pub config: Option<String>,
}

#[derive(Clone, Debug, Args, Serialize, Deserialize, Default)]
Expand Down
19 changes: 3 additions & 16 deletions tap_agent/src/tap/escrow_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,21 @@ impl EscrowAdapterTrait for EscrowAdapter {
)
.to_string(),
})?;

let fees = self
.sender_pending_fees
.read()
.await
.get(&sender)
.copied()
.ok_or(AdapterError::AdapterError {
error: format!(
"Gateway {} not found in pending fees map, could not get available escrow.",
sender
)
.to_string(),
})?;
.unwrap_or(0);
Ok(balance - fees)
}

async fn subtract_escrow(&self, sender: Address, value: u128) -> Result<(), AdapterError> {
let current_available_escrow = self.get_available_escrow(sender).await?;
let mut fees_write = self.sender_pending_fees.write().await;
let fees = fees_write
.get_mut(&sender)
.ok_or(AdapterError::AdapterError {
error: format!(
"Gateway {} not found in pending fees map, could not subtract available escrow.",
sender
)
.to_string(),
})?;
let fees = fees_write.entry(sender).or_insert(0);
if current_available_escrow < value {
return Err(AdapterError::AdapterError {
error: format!(
Expand Down
Loading

0 comments on commit 1d8f73e

Please sign in to comment.