Skip to content

Commit

Permalink
payment: allow changing deposit validation when amending an allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Jul 9, 2024
1 parent bd39f5c commit 406e9c2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ ya-service-api-interfaces = { path = "core/serv-api/interfaces" }
ya-service-api-web = { path = "core/serv-api/web" }

## CLIENT
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "ec1643bd27307310e8e5c8715a73967b6341ac60" }
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "b60640065835a1fc8eb33d2fb174ec6c0e4b30c4" }
#ya-client = { path = "../ya-client" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "ec1643bd27307310e8e5c8715a73967b6341ac60" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "b60640065835a1fc8eb33d2fb174ec6c0e4b30c4" }
#ya-client-model = "0.7"
golem-certificate = { git = "https://github.com/golemfactory/golem-certificate.git", rev = "f2d7514c18fc066e9cfb796090b90f5b27cfe1c6" }

Expand Down
13 changes: 13 additions & 0 deletions core/payment/src/api/allocations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,23 @@ fn amend_allocation_fields(
}
}

let deposit = match (old_allocation.deposit.clone(), update.deposit) {
(Some(deposit), None) => Some(deposit),
(Some(mut deposit), Some(deposit_update)) => {
deposit.validate = deposit_update.validate;
Some(deposit)
}
(None, None) => None,
(None, Some(_deposit_update)) => {
return Err("Cannot update deposit of an allocation created without one");
}
};

Ok(Allocation {
total_amount,
remaining_amount,
timeout: update.timeout.or(old_allocation.timeout),
deposit,
..old_allocation
})
}
Expand Down

0 comments on commit 406e9c2

Please sign in to comment.