-
Notifications
You must be signed in to change notification settings - Fork 407
Swap Vec<&RouteHop>
parameters for slices
#1728
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
Swap Vec<&RouteHop>
parameters for slices
#1728
Conversation
Codecov ReportBase: 90.73% // Head: 90.71% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1728 +/- ##
==========================================
- Coverage 90.73% 90.71% -0.02%
==========================================
Files 86 86
Lines 46675 46679 +4
Branches 46675 46679 +4
==========================================
- Hits 42350 42345 -5
- Misses 4325 4334 +9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, mod above feedback.
In c353c3e, new scorer-updating methods were added to the `Router` object, however they were passed as a `Vec` of references. We use the list-of-references pattern to make bindings simpler (by not requiring allocations per entry), however there's no reason prefer to passing a `Vec` over a slice, given the `Vec` doesn't hold ownership of the objects anyway.
In c353c3e an accessor method was added which returns an `Option<&u64>`. While this allows Rust to return an 8-byte object, returning a reference to something pointer-sized is a somewhat strange API. Instead, we opt for a straight `Option<u64>`, which is sadly somewhat larger on the stack, but is simpler and already supported in the bindings generation.
6d6b9cc
to
85eb1fd
Compare
Dropped the excess ampersands and went ahead and squashed since its super trivial: $ git diff-tree -U1 6d6b9cc4 85eb1fde
diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs
index 5af6cb766..3b4fe7092 100644
--- a/lightning-invoice/src/payment.rs
+++ b/lightning-invoice/src/payment.rs
@@ -1847,3 +1847,3 @@ mod tests {
fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) {
- self.scorer.lock().payment_path_failed(&path, short_channel_id);
+ self.scorer.lock().payment_path_failed(path, short_channel_id);
}
@@ -1851,3 +1851,3 @@ mod tests {
fn notify_payment_path_successful(&self, path: &[&RouteHop]) {
- self.scorer.lock().payment_path_successful(&path);
+ self.scorer.lock().payment_path_successful(path);
}
@@ -1855,3 +1855,3 @@ mod tests {
fn notify_payment_probe_successful(&self, path: &[&RouteHop]) {
- self.scorer.lock().probe_successful(&path);
+ self.scorer.lock().probe_successful(path);
}
@@ -1859,3 +1859,3 @@ mod tests {
fn notify_payment_probe_failed(&self, path: &[&RouteHop], short_channel_id: u64) {
- self.scorer.lock().probe_failed(&path, short_channel_id);
+ self.scorer.lock().probe_failed(path, short_channel_id);
}
diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs
index 8c96edbb0..5faecbfab 100644
--- a/lightning-invoice/src/utils.rs
+++ b/lightning-invoice/src/utils.rs
@@ -486,3 +486,3 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR
fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) {
- self.scorer.lock().payment_path_failed(&path, short_channel_id);
+ self.scorer.lock().payment_path_failed(path, short_channel_id);
}
@@ -490,3 +490,3 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR
fn notify_payment_path_successful(&self, path: &[&RouteHop]) {
- self.scorer.lock().payment_path_successful(&path);
+ self.scorer.lock().payment_path_successful(path);
}
@@ -494,3 +494,3 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR
fn notify_payment_probe_successful(&self, path: &[&RouteHop]) {
- self.scorer.lock().probe_successful(&path);
+ self.scorer.lock().probe_successful(path);
}
@@ -498,3 +498,3 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR
fn notify_payment_probe_failed(&self, path: &[&RouteHop], short_channel_id: u64) {
- self.scorer.lock().probe_failed(&path, short_channel_id);
+ self.scorer.lock().probe_failed(path, short_channel_id);
}
|
In c353c3e, new scorer-updating methods were added to the
Router
object, however they were passed as aVec
of references. We use the list-of-references pattern to make bindings simpler (by not requiring allocations per entry), however there's no reason prefer to passing aVec
over a slice, given theVec
doesn't hold ownership of the objects anyway.We also add a second commit which replaces an
Option<&u64>
with anOption<u64>
.