-
Notifications
You must be signed in to change notification settings - Fork 3
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
Define NetworkGraph
Trait for Flexible Routing
#24
Conversation
This commit introduces a `NetworkGraph` trait in `barq-common`, to allow for more flexibility in routing algorithms by supporting various graph structures. The `NetworkGraph` trait includes methods to handle network graphs with channels, nodes, and peer-to-peer information. This update includes: - Defining a `NetworkGraph` trait with methods to get channels, nodes, individual nodes and channels by ID, and to check for peer-to-peer information. - Renaming `Edge` to `Channel` to better reflect its role in the network graph. - Adding a `strategy` field to `BarqPayRequest` and `BarqRouteInfoRequest` to specify routing strategies. Signed-off-by: Tarek <[email protected]>
…ources - Introduce two modules in `barq-plugin` to manage network graph data: - `methods::graph::cln`: Uses information from CLN's `listchannels`. - `methods::graph::p2p`: Uses data from the gossip map. - Each module exposes a function to return the respective graph. - Update `barq-plugin` commands (`pay` and `routeinfo`) to select the appropriate graph source based on the specified strategy: - If the strategy is "probabilistic", use the `p2p` graph for routing with LDK. - Otherwise, use the `cln` graph based on CLN's `listchannels`. - Default to the "direct" routing strategy if the user does not specify a strategy. Signed-off-by: Tarek <[email protected]>
Should also fix #10 |
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.
Ok unfortunatly this need another iteration
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | ||
pub struct Edge { | ||
pub struct Channel { |
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.
I like to call this edge, then in the lightning network is a channel, but in a graph is always an edge
barq-common/src/graph.rs
Outdated
assert!(graph.get_edge("channel1").is_some()); | ||
assert_eq!(graph.get_node("node1").unwrap().channels.len(), 1); | ||
} | ||
/// Whether or not the network graph has peer-to-peer information (e.g., gossip map). |
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.
graph has peer-to-peer network information
barq-common/src/strategy.rs
Outdated
// If no strategy can be applied, return None | ||
Ok(None) | ||
// For now, we will just use the direct strategy | ||
Ok(Some(Box::new(Direct::new()))) |
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.
Can you use the Arc::new()
? Arch it is a little bit better to pass around
nodes: HashMap<String, Node>, | ||
channels: HashMap<String, Channel>, |
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.
ok but I think this si still slow, but in this case we can't do better
@@ -31,7 +31,7 @@ def test_pay_amounts(node_factory): | |||
l1.rpc.call("barqpay", {"bolt11_invoice": inv}) | |||
|
|||
invoice = only_one(l2.rpc.listinvoices('test_pay_amounts')['invoices']) | |||
assert invoice['amount_received_msat'] >= Millisatoshi(123000) | |||
assert invoice['amount_msat'] >= Millisatoshi(123000) |
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.
you need to explain in the commit body why, also for me that I am a contributor of core lightning, this does not make any sense
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Vincenzo Palazzo <[email protected]>
4ae2529
to
49731b6
Compare
Description
This pull request defines the
NetworkGraph
trait inbarq-common
, to enhance routing flexibilityKey Changes:
Define
NetworkGraph
TraitEdge
toChannel
strategy
field toBarqPayRequest
andBarqRouteInfoRequest
.Introduce Modules for Handling Different Network Graph Sources
barq-plugin
:methods::graph::cln
: Uses information from CLN'slistchannels
.methods::graph::p2p
: Uses data from the gossip map.pay
androuteinfo
commands to choose the appropriate graph source based on the specified strategy, defaulting to "direct" if not specified.Fix Tests
amount_received_msat
toamount_msat
For more detailed information, please refer to the individual commit messages and bodies.