Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix payment status in golemsp for multiple drivers #2860

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion golem_cli/src/command/yagna.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ lazy_static! {
name: "erc20next",
}
};
pub static ref DRIVERS: Vec<&'static PaymentDriver> = vec![&ERC20_DRIVER];

// Drivers are searched in order when more than one supports a given network,
// so erc20next should be preferred over erc20.
pub static ref DRIVERS: Vec<&'static PaymentDriver> = vec![&ERC20NEXT_DRIVER, &ERC20_DRIVER];
}

impl PaymentDriver {
Expand Down
19 changes: 13 additions & 6 deletions golem_cli/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ use ya_core_model::NodeId;

use crate::appkey;
use crate::command::{
NetworkGroup, PaymentSummary, YaCommand, DRIVERS, ERC20_DRIVER, NETWORK_GROUP_MAP,
NetworkGroup, PaymentDriver, PaymentSummary, YaCommand, DRIVERS, ERC20_DRIVER,
NETWORK_GROUP_MAP,
};
use crate::platform::Status as KvmStatus;
use crate::utils::{is_yagna_running, payment_account};

fn get_driver_for_network(network: &NetworkName) -> Option<&PaymentDriver> {
DRIVERS
.iter()
.find(|drv| drv.platform(network).is_ok())
.as_deref()
.copied()
}

async fn payment_status(
cmd: &YaCommand,
network: &NetworkName,
Expand All @@ -32,11 +41,9 @@ async fn payment_status(
let mut f = vec![];
let mut l = vec![];
for nn in NETWORK_GROUP_MAP[&network_group].iter() {
for driver in DRIVERS.iter() {
if driver.platform(nn).is_ok() {
l.push(driver.status_label(nn));
f.push(cmd.yagna()?.payment_status(&address, nn, driver));
}
if let Some(driver) = get_driver_for_network(nn) {
l.push(driver.status_label(nn));
f.push(cmd.yagna()?.payment_status(&address, nn, driver));
}
}
(f, l)
Expand Down
Loading