Skip to content

Commit

Permalink
Boss/Msg/RequestDowser.hpp: Make explicit that dowsing has a direction.
Browse files Browse the repository at this point in the history
Channel directions can be individually active or inactive, which affects
routing directions.
Thus, a dowsing request in on direction may have a different result in
the opposite direction.

Existing clients of the `Dowser` assume the first argument is the source
(proposal) and the second argument is the destination (patron), but the
`Dowser` used the first argument as the destination instead.
This also flips the `Dowser` direction.
  • Loading branch information
ZmnSCPxj committed Nov 17, 2020
1 parent 22283a1 commit 94d779b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
20 changes: 11 additions & 9 deletions Boss/Mod/Dowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Dowser::Run : public std::enable_shared_from_this<Run> {
private:
S::Bus& bus;
void* requester;
Ln::NodeId a;
Ln::NodeId b;
Ln::NodeId fromid;
Ln::NodeId toid;

Boss::Mod::Rpc* rpc;
Ln::NodeId self_id;
Expand All @@ -60,12 +60,12 @@ class Dowser::Run : public std::enable_shared_from_this<Run> {
public:
Run( S::Bus& bus_
, void* requester_
, Ln::NodeId const& a_
, Ln::NodeId const& b_
, Ln::NodeId const& fromid_
, Ln::NodeId const& toid_
) : bus(bus_)
, requester(requester_)
, a(a_)
, b(b_)
, fromid(fromid_)
, toid(toid_)
{ }

Ev::Io<void> run( Boss::Mod::Rpc& rpc_
Expand Down Expand Up @@ -122,8 +122,8 @@ class Dowser::Run : public std::enable_shared_from_this<Run> {
auto exc = get_excludes();
auto params = Json::Out()
.start_object()
.field("id", std::string(a))
.field("fromid", std::string(b))
.field("id", std::string(toid))
.field("fromid", std::string(fromid))
.field("msatoshi", "1msat")
/* I never had a decent grasp of
* riskfactor. */
Expand Down Expand Up @@ -353,7 +353,9 @@ void Dowser::start() {
});
bus.subscribe<Msg::RequestDowser
>([this](Msg::RequestDowser const& r) {
auto run = std::make_shared<Run>(bus, r.requester, r.a, r.b);
auto run = std::make_shared<Run>( bus, r.requester
, r.fromid, r.toid
);
return Ev::lift().then([this]() {
return wait_for_rpc(rpc);
}).then([this, run]() {
Expand Down
4 changes: 2 additions & 2 deletions Boss/Msg/RequestDowser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Boss { namespace Msg {
*/
struct RequestDowser {
void* requester;
Ln::NodeId a;
Ln::NodeId b;
Ln::NodeId fromid;
Ln::NodeId toid;
};

}}
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Properly consider direction of flow when estimating capacities of nodes.
- Properly rebalance channels greater than 42.94mBTC payment limit.
- Use `payment_secret` in rebalances.
- Work around a timing bug in Tor SOCKS5 implementation.
Expand Down

0 comments on commit 94d779b

Please sign in to comment.