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 build_router fee rate issue #323

Merged
merged 5 commits into from
Nov 20, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
tool: nextest
- run: |
RUST_BACKTRACE=full RUST_LOG=trace cargo nextest run
RUST_BACKTRACE=full RUST_LOG=trace cargo nextest run --no-fail-fast

fmt:
name: Rustfmt
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GRCOV_EXCL_LINE = ^\s*(\})*(\))*(;)*$$|\s*((log::|tracing::)?(trace|debug|info|w

.PHONY: test
test:
RUST_LOG=off cargo nextest run
RUST_LOG=off cargo nextest run --no-fail-fast

.PHONY: clippy
clippy:
Expand Down
26 changes: 19 additions & 7 deletions src/fiber/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ impl ChannelInfo {
pub fn funding_tx_block_number(&self) -> u64 {
self.funding_tx_block_number
}

fn get_update_info_with(&self, node: Pubkey) -> Option<&ChannelUpdateInfo> {
if self.node2() == node {
self.node1_to_node2.as_ref()
} else if self.node1() == node {
self.node2_to_node1.as_ref()
} else {
None
}
}
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -520,6 +530,11 @@ where
self.history.reset();
}

#[cfg(test)]
pub fn set_source(&mut self, source: Pubkey) {
self.source = source;
}

/// Returns a list of `PaymentHopData` for all nodes in the route,
/// including the origin and the target node.
pub fn build_route(
Expand Down Expand Up @@ -579,14 +594,11 @@ where
(0, 0)
} else {
let channel_info = self
.get_channel(&route[i + 1].channel_outpoint)
.get_channel(&route[i].channel_outpoint)
.expect("channel not found");
let channel_update = &if channel_info.node1() == route[i + 1].target {
channel_info.node2_to_node1.as_ref()
} else {
channel_info.node1_to_node2.as_ref()
}
.expect("channel_update is none");
let channel_update = channel_info
.get_update_info_with(route[i].target)
.expect("channel_update is none");
let fee_rate = channel_update.fee_rate;
let fee = calculate_tlc_forward_fee(current_amount, fee_rate as u128);
let expiry = channel_update.htlc_expiry_delta;
Expand Down
Loading
Loading