Skip to content

Commit

Permalink
Merge pull request fedimint#5889 from m1sterc001guy/upgrade_follow_up
Browse files Browse the repository at this point in the history
chore: cln extension upgrade follow ups
  • Loading branch information
bradleystachurski authored Aug 20, 2024
2 parents 9287bf0 + 8ffb7d5 commit 9dda901
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
19 changes: 9 additions & 10 deletions devimint/src/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use fedimint_core::BitcoinHash;
use fedimint_logging::LOG_DEVIMINT;
use fedimint_testing::gateway::LightningNodeType;
use hex::ToHex;
use itertools::Itertools;
use tokio::fs;
use tokio::sync::{MappedMutexGuard, Mutex, MutexGuard};
use tokio::time::Instant;
Expand Down Expand Up @@ -890,16 +891,14 @@ pub async fn open_channels_between_gateways(

// All unique pairs of gateways.
// For a list of gateways [A, B, C], this will produce [(A, B), (B, C), (C, A)].
// Order needs to be enforced so that each Lightning node opens 1 channel.
let mut gateway_pairs = Vec::new();
for i in 0..gateways.len() {
let next = (i + 1) % gateways.len();
gateway_pairs.push((gateways[i], gateways[next]));
// Exit early if there is only one pair of gateways
if gateways.len() == 2 {
break;
}
}
// Since the first gateway within each pair initiates the channel open,
// order within each pair needs to be enforced so that each Lightning node opens
// 1 channel.
let gateway_pairs: Vec<(&(&Gatewayd, &str), &(&Gatewayd, &str))> = if gateways.len() == 2 {
gateways.iter().tuple_windows::<(_, _)>().collect()
} else {
gateways.iter().circular_tuple_windows::<(_, _)>().collect()
};

for ((gw_a, gw_a_name), (gw_b, gw_b_name)) in &gateway_pairs {
let push_amount = 5_000_000;
Expand Down
11 changes: 11 additions & 0 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ export -f filter_count
function nix_build_binary_for_version() {
binary="$1"
version="$2"

# nix flake did not build gateway-cln-extension prior to v0.4.0
if [[ ("$version" =~ ^v0\.[23]) && "$binary" == "gateway-cln-extension" ]] ; then
version="v0.4.0"
fi

>&2 echo "Compiling ${binary} for version ${version} ..."
echo "$(nix build 'github:fedimint/fedimint/'"$version"'#'"$binary" --no-link --print-out-paths)/bin/$binary"
}
Expand Down Expand Up @@ -158,6 +164,7 @@ function use_gateway_binaries_for_version() {
if [[ "$version" == "current" ]]; then
unset FM_GATEWAYD_BASE_EXECUTABLE
unset FM_GATEWAY_CLI_BASE_EXECUTABLE
unset FM_GATEWAY_CLN_EXTENSION_BASE_EXECUTABLE
else
var_name=$(nix_binary_version_var_name gatewayd "$version")
FM_GATEWAYD_BASE_EXECUTABLE="${!var_name}"
Expand All @@ -166,6 +173,10 @@ function use_gateway_binaries_for_version() {
var_name=$(nix_binary_version_var_name gateway-cli "$version")
FM_GATEWAY_CLI_BASE_EXECUTABLE="${!var_name}"
export FM_GATEWAY_CLI_BASE_EXECUTABLE

var_name=$(nix_binary_version_var_name gateway-cln-extension "$version")
FM_GATEWAY_CLN_EXTENSION_BASE_EXECUTABLE="${!var_name}"
export FM_GATEWAY_CLN_EXTENSION_BASE_EXECUTABLE
fi
}
export -f use_gateway_binaries_for_version
Expand Down

0 comments on commit 9dda901

Please sign in to comment.